Skip to content

Commit

Permalink
Updating with more robust sorting tests
Browse files Browse the repository at this point in the history
  • Loading branch information
deckarep committed Jan 6, 2024
1 parent a3f4602 commit cc2af11
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pkg/sorting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,21 @@ func TestDynamicSortDevices(t *testing.T) {
{
Device: tailscale.Device{
Name: "b-foo",
User: "chestnut@foo.com",
},
EnrichedInfo: nil,
},
{
Device: tailscale.Device{
Name: "a-foo",
User: "peanut@foo.com",
},
EnrichedInfo: nil,
},
{
Device: tailscale.Device{
Name: "c-foo",
User: "walnut@foo.com",
},
EnrichedInfo: nil,
},
Expand All @@ -69,13 +72,13 @@ func TestDynamicSortDevices(t *testing.T) {
assert.Equal(t, inputDevs[2].Name, "c-foo")

specs = []SortSpec{{
Field: "NAME",
Field: "USER",
Direction: Descending,
}}

dynamicSortDevices(inputDevs, specs)

assert.Equal(t, inputDevs[0].Name, "c-foo")
assert.Equal(t, inputDevs[1].Name, "b-foo")
assert.Equal(t, inputDevs[2].Name, "a-foo")
assert.Equal(t, inputDevs[0].User, "walnut@foo.com")
assert.Equal(t, inputDevs[1].User, "peanut@foo.com")
assert.Equal(t, inputDevs[2].User, "chestnut@foo.com")
}

0 comments on commit cc2af11

Please sign in to comment.