Files
nomad/command/scaling_policy_test.go
Seth Hoenig 4d83733909 tests: swap testify for test in more places (#20028)
* tests: swap testify for test in plugins/csi/client_test.go

* tests: swap testify for test in testutil/

* tests: swap testify for test in host_test.go

* tests: swap testify for test in plugin_test.go

* tests: swap testify for test in utils_test.go

* tests: swap testify for test in scheduler/

* tests: swap testify for test in parse_test.go

* tests: swap testify for test in attribute_test.go

* tests: swap testify for test in plugins/drivers/

* tests: swap testify for test in command/

* tests: fixup some test usages

* go: run go mod tidy

* windows: cpuset test only on linux
2024-02-29 12:11:35 -06:00

56 lines
1.2 KiB
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package command
import (
"testing"
"github.com/hashicorp/nomad/ci"
"github.com/shoenig/test/must"
)
func Test_formatScalingPolicyTarget(t *testing.T) {
ci.Parallel(t)
testCases := []struct {
inputMap map[string]string
expectedOutput string
name string
}{
{
inputMap: map[string]string{
"Namespace": "default",
"Job": "example",
"Group": "cache",
},
expectedOutput: "Namespace:default,Job:example,Group:cache",
name: "generic horizontal scaling policy target",
},
{
inputMap: map[string]string{
"Namespace": "default",
"Job": "example",
"Group": "cache",
"Unknown": "alien",
},
expectedOutput: "Namespace:default,Job:example,Group:cache,Unknown:alien",
name: "extra key in input mapping",
},
{
inputMap: map[string]string{
"Namespace": "default",
},
expectedOutput: "Namespace:default",
name: "single entry in map",
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
actualOutput := formatScalingPolicyTarget(tc.inputMap)
must.Eq(t, tc.expectedOutput, actualOutput)
})
}
}