Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ribice committed Jun 29, 2022
1 parent 047e938 commit a2ffc59
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions glice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,48 @@ func TestPrint(t *testing.T) {
}
}

func TestPrintTo(t *testing.T) {
tests := map[string]struct {
path string
format string
wantWriteOutput bool
wantErr bool
}{
"invalid path": {
path: "invalid",
wantErr: true,
},
"json format": {
path: wd(),
wantWriteOutput: true,
format: "json",
},
"csv format": {
path: wd(),
wantWriteOutput: true,
format: "csv",
},
"valid path": {
path: wd(),
wantWriteOutput: true,
format: "table",
},
}
for name, tt := range tests {
t.Run(name, func(t *testing.T) {
writeTo := &bytes.Buffer{}
err := PrintTo(tt.path, tt.format, "stdout", false, writeTo)
if (err != nil) != tt.wantErr {
t.Errorf("Print() error = %v, wantErr %v", err, tt.wantErr)
return
}
if (writeTo.String() != "") != tt.wantWriteOutput {
t.Error("wantWriteOutput and gotOutput do not match")
}
})
}
}

func TestClient_Print(t *testing.T) {
tests := map[string]struct {
dependencies []*Repository
Expand Down

0 comments on commit a2ffc59

Please sign in to comment.