You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
boundary/internal/scheduler/job/options_test.go

49 lines
1.2 KiB

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
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) {
assert := assert.New(t)
opts := getOpts(WithControllerId("controller_id"))
testOpts := getDefaultOptions()
assert.NotEqual(opts, testOpts)
testOpts.withControllerId = "controller_id"
assert.Equal(opts, testOpts)
})
}