Created
May 4, 2020 19:40
-
-
Save plutov/f2d7815a9064694c090955aa62776d4e to your computer and use it in GitHub Desktop.
testable5.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func TestGetAverageStarsPerRepo(t *testing.T) { | |
var tests = []struct { | |
username string | |
want float64 | |
}{ | |
{"octocat", 1480.375000}, | |
{"plutov", 15.566667}, | |
} | |
for _, tt := range tests { | |
t.Run(tt.username, func(t *testing.T) { | |
got, err := GetAverageStarsPerRepo(tt.username) | |
// Don't omit errors even in tests | |
if err != nil { | |
t.Errorf("expecting nil err, got %v", err) | |
} | |
if got != tt.want { | |
t.Errorf("expecting %f, got %f", tt.want, got) | |
} | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment