github.com/hernad/nomad@v1.6.112/nomad/structs/config/autopilot_test.go (about) 1 // Copyright (c) HashiCorp, Inc. 2 // SPDX-License-Identifier: MPL-2.0 3 4 package config 5 6 import ( 7 "reflect" 8 "testing" 9 "time" 10 11 "github.com/hernad/nomad/ci" 12 ) 13 14 func TestAutopilotConfig_Merge(t *testing.T) { 15 ci.Parallel(t) 16 17 trueValue, falseValue := true, false 18 19 c1 := &AutopilotConfig{ 20 CleanupDeadServers: &falseValue, 21 ServerStabilizationTime: 1 * time.Second, 22 LastContactThreshold: 1 * time.Second, 23 MaxTrailingLogs: 1, 24 MinQuorum: 1, 25 EnableRedundancyZones: &trueValue, 26 DisableUpgradeMigration: &falseValue, 27 EnableCustomUpgrades: &trueValue, 28 } 29 30 c2 := &AutopilotConfig{ 31 CleanupDeadServers: &trueValue, 32 ServerStabilizationTime: 2 * time.Second, 33 LastContactThreshold: 2 * time.Second, 34 MaxTrailingLogs: 2, 35 MinQuorum: 2, 36 EnableRedundancyZones: nil, 37 DisableUpgradeMigration: nil, 38 EnableCustomUpgrades: nil, 39 } 40 41 e := &AutopilotConfig{ 42 CleanupDeadServers: &trueValue, 43 ServerStabilizationTime: 2 * time.Second, 44 LastContactThreshold: 2 * time.Second, 45 MaxTrailingLogs: 2, 46 MinQuorum: 2, 47 EnableRedundancyZones: &trueValue, 48 DisableUpgradeMigration: &falseValue, 49 EnableCustomUpgrades: &trueValue, 50 } 51 52 result := c1.Merge(c2) 53 if !reflect.DeepEqual(result, e) { 54 t.Fatalf("bad:\n%#v\n%#v", result, e) 55 } 56 }