Skip to content

Commit

Permalink
Breaks out TestNewTransmission into subtests.
Browse files Browse the repository at this point in the history
  • Loading branch information
FabienTregan committed Jun 17, 2018
1 parent d7f1c32 commit c82d2da
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions workspace/transmission_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestNewTransmission(t *testing.T) {
fileBird := filepath.Join(dirBird, "hummingbird.txt")
fileSugar := filepath.Join(dirFeeder, "sugar.txt")

tests := []struct {
testCases := []struct {
desc string
args []string
ok bool
Expand Down Expand Up @@ -65,18 +65,20 @@ func TestNewTransmission(t *testing.T) {
},
}

for _, test := range tests {
tx, err := NewTransmission(root, test.args)
if test.ok {
assert.NoError(t, err, test.desc)
} else {
assert.Error(t, err, test.desc)
}
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
tx, err := NewTransmission(root, tc.args)
if tc.ok {

This comment has been minimized.

Copy link
@nywilken

nywilken Jun 19, 2018

Contributor

Wondering if we should just ignore the error or be explicit about the expectations for the value of tc.ok. The if/else doesn’t seem to validate or test anything

assert.NoError(t, err, tc.desc)
} else {
assert.Error(t, err, tc.desc)
}

if test.tx != nil {
assert.Equal(t, test.tx.Files, tx.Files, test.desc)
assert.Equal(t, test.tx.Dir, tx.Dir, test.desc)
}
if tc.tx != nil {
assert.Equal(t, tc.tx.Files, tx.Files)
assert.Equal(t, tc.tx.Dir, tx.Dir)
}
})
}
}

Expand Down

0 comments on commit c82d2da

Please sign in to comment.