Files
threshold/internal/scheduler/job/options_test.go
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

48 lines
1.2 KiB
Go
Raw Normal View History

2023-02-02 17:15:17 -08:00
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
2021-05-06 14:54:10 -07:00
package job
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
// Test_GetOpts provides unit tests for GetOpts and all the options
func Test_GetOpts(t *testing.T) {
t.Parallel()
t.Run("WithNextRunIn", func(t *testing.T) {
assert := assert.New(t)
opts := getOpts(WithNextRunIn(time.Hour))
testOpts := getDefaultOptions()
assert.NotEqual(opts, testOpts)
testOpts.withNextRunIn = time.Hour
assert.Equal(opts, testOpts)
})
t.Run("WithLimit", func(t *testing.T) {
assert := assert.New(t)
opts := getOpts(WithLimit(100))
testOpts := getDefaultOptions()
assert.NotEqual(opts, testOpts)
testOpts.withLimit = 100
assert.Equal(opts, testOpts)
})
t.Run("WithName", func(t *testing.T) {
assert := assert.New(t)
opts := getOpts(WithName("name"))
testOpts := getDefaultOptions()
assert.NotEqual(opts, testOpts)
testOpts.withName = "name"
assert.Equal(opts, testOpts)
})
t.Run("WithControllerId", func(t *testing.T) {
2021-05-06 14:54:10 -07:00
assert := assert.New(t)
opts := getOpts(WithControllerId("controller_id"))
2021-05-06 14:54:10 -07:00
testOpts := getDefaultOptions()
assert.NotEqual(opts, testOpts)
testOpts.withControllerId = "controller_id"
2021-05-06 14:54:10 -07:00
assert.Equal(opts, testOpts)
})
}