Skip to content

Commit

Permalink
backport of commit 38e1c7d
Browse files Browse the repository at this point in the history
  • Loading branch information
shoenig committed Mar 13, 2023
1 parent 9d896b8 commit f477dcf
Showing 1 changed file with 38 additions and 13 deletions.
51 changes: 38 additions & 13 deletions nomad/structs/structs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2848,49 +2848,74 @@ func TestTaskWaitConfig_Equals(t *testing.T) {
ci.Parallel(t)

testCases := []struct {
name string
config *WaitConfig
expected *WaitConfig
name string
wc1 *WaitConfig
wc2 *WaitConfig
exp bool
}{
{
name: "all-fields",
config: &WaitConfig{
wc1: &WaitConfig{
Min: pointer.Of(5 * time.Second),
Max: pointer.Of(10 * time.Second),
},
expected: &WaitConfig{
wc2: &WaitConfig{
Min: pointer.Of(5 * time.Second),
Max: pointer.Of(10 * time.Second),
},
exp: true,
},
{
name: "no-fields",
config: &WaitConfig{},
expected: &WaitConfig{},
name: "no-fields",
wc1: &WaitConfig{},
wc2: &WaitConfig{},
exp: true,
},
{
name: "min-only",
config: &WaitConfig{
wc1: &WaitConfig{
Min: pointer.Of(5 * time.Second),
},
expected: &WaitConfig{
wc2: &WaitConfig{
Min: pointer.Of(5 * time.Second),
},
exp: true,
},
{
name: "max-only",
config: &WaitConfig{
wc1: &WaitConfig{
Max: pointer.Of(10 * time.Second),
},
expected: &WaitConfig{
wc2: &WaitConfig{
Max: pointer.Of(10 * time.Second),
},
exp: true,
},
{
name: "min-nil-vs-set",
wc1: &WaitConfig{
Min: pointer.Of(1 * time.Second),
},
wc2: &WaitConfig{
Min: nil,
},
exp: false,
},
{
name: "max-nil-vs-set",
wc1: &WaitConfig{
Max: pointer.Of(1 * time.Second),
},
wc2: &WaitConfig{
Max: nil,
},
exp: false,
},
}

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
require.True(t, tc.config.Equal(tc.expected))
must.Eq(t, tc.exp, tc.wc1.Equal(tc.wc2))
})
}
}
Expand Down

0 comments on commit f477dcf

Please sign in to comment.