Skip to content

Instantly share code, notes, and snippets.

@tjdevries
Created January 20, 2022 21:48
Show Gist options
  • Select an option

  • Save tjdevries/7f9b45be5c2648fbee12c84885494a1d to your computer and use it in GitHub Desktop.

Select an option

Save tjdevries/7f9b45be5c2648fbee12c84885494a1d to your computer and use it in GitHub Desktop.

Revisions

  1. tjdevries created this gist Jan 20, 2022.
    30 changes: 30 additions & 0 deletions bash_test_example.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    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)
    }
    }