github.com/TeaOSLab/EdgeNode@v1.3.8/internal/metrics/manager_test.go (about) 1 // Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved. 2 3 package metrics_test 4 5 import ( 6 "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" 7 "github.com/TeaOSLab/EdgeNode/internal/metrics" 8 "testing" 9 ) 10 11 func TestNewManager(t *testing.T) { 12 var manager = metrics.NewManager() 13 { 14 manager.Update([]*serverconfigs.MetricItemConfig{}) 15 for _, task := range manager.TaskMap() { 16 t.Log(task.Item().Id) 17 } 18 } 19 { 20 t.Log("====") 21 manager.Update([]*serverconfigs.MetricItemConfig{ 22 { 23 Id: 1, 24 }, 25 { 26 Id: 2, 27 }, 28 { 29 Id: 3, 30 }, 31 }) 32 for _, task := range manager.TaskMap() { 33 t.Log("task:", task.Item().Id) 34 } 35 } 36 37 { 38 t.Log("====") 39 manager.Update([]*serverconfigs.MetricItemConfig{ 40 { 41 Id: 1, 42 }, 43 { 44 Id: 2, 45 }, 46 }) 47 for _, task := range manager.TaskMap() { 48 t.Log("task:", task.Item().Id) 49 } 50 } 51 52 { 53 t.Log("====") 54 manager.Update([]*serverconfigs.MetricItemConfig{ 55 { 56 Id: 1, 57 Version: 1, 58 }, 59 }) 60 for _, task := range manager.TaskMap() { 61 t.Log("task:", task.Item().Id) 62 } 63 } 64 }