Skip to content

Instantly share code, notes, and snippets.

@tjdevries
Created January 20, 2022 21:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjdevries/7f9b45be5c2648fbee12c84885494a1d to your computer and use it in GitHub Desktop.
Save tjdevries/7f9b45be5c2648fbee12c84885494a1d to your computer and use it in GitHub Desktop.
func TestNoProjects(t *testing.T) {
db := Setup(t)
pr := &GormProjectRepository{DB: db}
// Don't add any projects
// Test
allProjects := GetProjects(pr)
if len(allProjects) > 0 {
t.Errorf("Shouldn't have any projects, but got: %+v\n", allProjects)
}
}
func TestOneProject(t *testing.T) {
db := Setup(t)
pr := &GormProjectRepository{DB: db}
// Add one project this time.
addProject(pr, "MyProject")
allProjects := GetProjects(pr)
if len(allProjects) != 1 {
t.Errorf("Should have gotten one pro, but got: %+v\n", allProjects)
}
proj := allProjects[0]
if pr.name != "MyProject" {
t.Errorf("Should have gotten 'MyProject', but got '%+v'\n", proj)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment