github.com/shuguocloud/go-zero@v1.3.0/core/trace/agent_test.go (about) 1 package trace 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 "github.com/shuguocloud/go-zero/core/logx" 8 ) 9 10 func TestStartAgent(t *testing.T) { 11 logx.Disable() 12 13 const ( 14 endpoint1 = "localhost:1234" 15 endpoint2 = "remotehost:1234" 16 endpoint3 = "localhost:1235" 17 ) 18 c1 := Config{ 19 Name: "foo", 20 } 21 c2 := Config{ 22 Name: "bar", 23 Endpoint: endpoint1, 24 Batcher: kindJaeger, 25 } 26 c3 := Config{ 27 Name: "any", 28 Endpoint: endpoint2, 29 Batcher: kindZipkin, 30 } 31 c4 := Config{ 32 Name: "bla", 33 Endpoint: endpoint3, 34 Batcher: "otlp", 35 } 36 37 StartAgent(c1) 38 StartAgent(c1) 39 StartAgent(c2) 40 StartAgent(c3) 41 StartAgent(c4) 42 43 lock.Lock() 44 defer lock.Unlock() 45 46 // because remotehost cannot be resolved 47 assert.Equal(t, 2, len(agents)) 48 _, ok := agents[""] 49 assert.True(t, ok) 50 _, ok = agents[endpoint1] 51 assert.True(t, ok) 52 _, ok = agents[endpoint2] 53 assert.False(t, ok) 54 }