Skip to content

Commit

Permalink
Additional edge case unit-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
deckarep committed Jan 13, 2024
1 parent 95eb886 commit 9e618a4
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions pkg/processors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,30 @@ func TestProcessDevicesTable(t *testing.T) {
},
}

// Single slice - 0:1
tv, err := ProcessDevicesTable(ctx, devList)
assert.NoError(t, err)

// TODO: more robust assertions on the output.
assert.Equal(t, len(tv.Rows), 1, "the general table view should have two rows")
assert.Equal(t, len(tv.Rows), 1, "the general table view should have a single row")

// slice from 0:(everything else)
cfgCtx.Slice = ParseSlice("0:", 0)
tv, err = ProcessDevicesTable(ctx, devList)
assert.NoError(t, err)

assert.Equal(t, len(tv.Rows), 2, "the general table view should have a single row")

// slice from :1
cfgCtx.Slice = ParseSlice(":1", 0)
tv, err = ProcessDevicesTable(ctx, devList)
assert.NoError(t, err)

assert.Equal(t, len(tv.Rows), 1, "the general table view should have a single row")

// slice from 0:50 - overly large slice.
cfgCtx.Slice = ParseSlice("0:50", 0)
tv, err = ProcessDevicesTable(ctx, devList)
assert.NoError(t, err)

assert.Equal(t, len(tv.Rows), 2, "the general table view should have a single row")
}

0 comments on commit 9e618a4

Please sign in to comment.