github.com/GuanceCloud/cliutils@v1.1.21/pipeline/manager/relation_test.go (about) 1 // Unless explicitly stated otherwise all files in this repository are licensed 2 // under the MIT License. 3 // This product includes software developed at Guance Cloud (https://www.guance.com/). 4 // Copyright 2021-present Guance, Inc. 5 6 // Package manager for managing pipeline scripts 7 package manager 8 9 import ( 10 "testing" 11 12 "github.com/GuanceCloud/cliutils/point" 13 "github.com/stretchr/testify/assert" 14 ) 15 16 func TestRelation(t *testing.T) { 17 rl := NewPipelineRelation() 18 19 rl.UpdateRelation(0, map[point.Category]map[string]string{ 20 point.Logging: { 21 "abc": "a1.p", 22 }, 23 }) 24 p, ok := rl.Query(point.Logging, "abc") 25 assert.True(t, ok) 26 assert.Equal(t, "a1.p", p) 27 28 p, ok = rl.Query(point.Logging, "def") 29 assert.False(t, ok) 30 assert.Equal(t, "", p) 31 32 name, ok := ScriptName(rl, point.Logging, point.NewPointV2("abc", point.NewKVs(map[string]interface{}{"message@json": "a"})), nil) 33 assert.True(t, ok) 34 assert.Equal(t, "a1.p", name) 35 36 name, ok = ScriptName(rl, point.Logging, point.NewPointV2("abcd", point.NewKVs(map[string]interface{}{"message@json": "a"})), map[string]string{"abcd": "a2.p"}) 37 assert.True(t, ok) 38 assert.Equal(t, "a2.p", name) 39 }