github.com/sl1pm4t/consul@v1.4.5-0.20190325224627-74c31c540f9c/agent/config/segment_oss_test.go (about) 1 // +build !ent 2 3 package config 4 5 import ( 6 "os" 7 "testing" 8 9 "github.com/hashicorp/consul/testutil" 10 ) 11 12 func TestSegments(t *testing.T) { 13 dataDir := testutil.TempDir(t, "consul") 14 defer os.RemoveAll(dataDir) 15 16 tests := []configTest{ 17 { 18 desc: "segment name not in OSS", 19 args: []string{ 20 `-data-dir=` + dataDir, 21 }, 22 json: []string{`{ "server": true, "segment": "a" }`}, 23 hcl: []string{` server = true segment = "a" `}, 24 err: `Network segments are not supported in this version of Consul`, 25 }, 26 { 27 desc: "segment port must be set", 28 args: []string{ 29 `-data-dir=` + dataDir, 30 }, 31 json: []string{`{ "segments":[{ "name":"x" }] }`}, 32 hcl: []string{`segments = [{ name = "x" }]`}, 33 err: `Port for segment "x" cannot be <= 0`, 34 }, 35 { 36 desc: "segments not in OSS", 37 args: []string{ 38 `-data-dir=` + dataDir, 39 }, 40 json: []string{`{ "segments":[{ "name":"x", "port": 123 }] }`}, 41 hcl: []string{`segments = [{ name = "x" port = 123 }]`}, 42 err: `Network segments are not supported in this version of Consul`, 43 }, 44 } 45 46 testConfig(t, tests, dataDir) 47 }