github.com/smithx10/nomad@v0.9.1-rc1/client/config/config_test.go (about)

     1  package config
     2  
     3  import "testing"
     4  
     5  func TestConfigRead(t *testing.T) {
     6  	config := Config{}
     7  
     8  	actual := config.Read("cake")
     9  	if actual != "" {
    10  		t.Errorf("Expected empty string; found %s", actual)
    11  	}
    12  
    13  	expected := "chocolate"
    14  	config.Options = map[string]string{"cake": expected}
    15  	actual = config.Read("cake")
    16  	if actual != expected {
    17  		t.Errorf("Expected %s, found %s", expected, actual)
    18  	}
    19  }
    20  
    21  func TestConfigReadDefault(t *testing.T) {
    22  	config := Config{}
    23  
    24  	expected := "vanilla"
    25  	actual := config.ReadDefault("cake", expected)
    26  	if actual != expected {
    27  		t.Errorf("Expected %s, found %s", expected, actual)
    28  	}
    29  
    30  	expected = "chocolate"
    31  	config.Options = map[string]string{"cake": expected}
    32  	actual = config.ReadDefault("cake", "vanilla")
    33  	if actual != expected {
    34  		t.Errorf("Expected %s, found %s", expected, actual)
    35  	}
    36  }