github.com/emate/nomad@v0.8.2-wo-binpacking/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  		EnableRedundancyZones:   &trueValue,
    18  		DisableUpgradeMigration: &falseValue,
    19  		EnableCustomUpgrades:    &trueValue,
    20  	}
    21  
    22  	c2 := &AutopilotConfig{
    23  		CleanupDeadServers:      &trueValue,
    24  		ServerStabilizationTime: 2 * time.Second,
    25  		LastContactThreshold:    2 * time.Second,
    26  		MaxTrailingLogs:         2,
    27  		EnableRedundancyZones:   nil,
    28  		DisableUpgradeMigration: nil,
    29  		EnableCustomUpgrades:    nil,
    30  	}
    31  
    32  	e := &AutopilotConfig{
    33  		CleanupDeadServers:      &trueValue,
    34  		ServerStabilizationTime: 2 * time.Second,
    35  		LastContactThreshold:    2 * time.Second,
    36  		MaxTrailingLogs:         2,
    37  		EnableRedundancyZones:   &trueValue,
    38  		DisableUpgradeMigration: &falseValue,
    39  		EnableCustomUpgrades:    &trueValue,
    40  	}
    41  
    42  	result := c1.Merge(c2)
    43  	if !reflect.DeepEqual(result, e) {
    44  		t.Fatalf("bad:\n%#v\n%#v", result, e)
    45  	}
    46  }