Skip to content

Instantly share code, notes, and snippets.

@plutov
Created May 4, 2020 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plutov/f2d7815a9064694c090955aa62776d4e to your computer and use it in GitHub Desktop.
Save plutov/f2d7815a9064694c090955aa62776d4e to your computer and use it in GitHub Desktop.
testable5.go
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