github.com/uchennaokeke444/nomad@v0.11.8/nomad/structs/config/autopilot_test.go (about)

     1  package config
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  	"time"
     7  )
     8  
     9  func TestAutopilotConfig_Merge(t *testing.T) {
    10  	trueValue, falseValue := true, false
    11  
    12  	c1 := &AutopilotConfig{
    13  		CleanupDeadServers:      &falseValue,
    14  		ServerStabilizationTime: 1 * time.Second,
    15  		LastContactThreshold:    1 * time.Second,
    16  		MaxTrailingLogs:         1,
    17  		MinQuorum:               1,
    18  		EnableRedundancyZones:   &trueValue,
    19  		DisableUpgradeMigration: &falseValue,
    20  		EnableCustomUpgrades:    &trueValue,
    21  	}
    22  
    23  	c2 := &AutopilotConfig{
    24  		CleanupDeadServers:      &trueValue,
    25  		ServerStabilizationTime: 2 * time.Second,
    26  		LastContactThreshold:    2 * time.Second,
    27  		MaxTrailingLogs:         2,
    28  		MinQuorum:               2,
    29  		EnableRedundancyZones:   nil,
    30  		DisableUpgradeMigration: nil,
    31  		EnableCustomUpgrades:    nil,
    32  	}
    33  
    34  	e := &AutopilotConfig{
    35  		CleanupDeadServers:      &trueValue,
    36  		ServerStabilizationTime: 2 * time.Second,
    37  		LastContactThreshold:    2 * time.Second,
    38  		MaxTrailingLogs:         2,
    39  		MinQuorum:               2,
    40  		EnableRedundancyZones:   &trueValue,
    41  		DisableUpgradeMigration: &falseValue,
    42  		EnableCustomUpgrades:    &trueValue,
    43  	}
    44  
    45  	result := c1.Merge(c2)
    46  	if !reflect.DeepEqual(result, e) {
    47  		t.Fatalf("bad:\n%#v\n%#v", result, e)
    48  	}
    49  }