You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

23 lines
1.1 KiB

package console
import "testing"
// 作用域归一里「谁拿原行、谁拿拷贝」由这个函数决定;用错列(name 而不是 app_name)会让
// 运行时按 ANALYZE_APP_NAME 一行都找不到,且不报错。
func TestScopeTargetApps(t *testing.T) {
apps := []*AppRegistry{
{Id: 17, Name: "deepglass", AppName: "deepGlass", Enabled: true},
{Id: 15, Name: "EAIMAR-TEST", AppName: "EAIMAR-TEST", Enabled: true},
{Id: 20, Name: "EAIMAR-HW", AppName: "EAIMAR-TEST", Enabled: true}, // 同一应用的第二个部署
{Id: 3, Name: "old", AppName: "Old", Enabled: false}, // 停用的不参与
{Id: 30, Name: "blank", AppName: " ", Enabled: true}, // 没填应用名的跳过
}
got := scopeTargetApps(apps)
if len(got) != 2 || got[0] != "EAIMAR-TEST" || got[1] != "deepGlass" {
t.Fatalf("应按 app_registry.id 升序取去重后的 app_name,实际 %v", got)
}
// 首个(拿原行的)必须是 id 最小的已启用应用,而不是部署名字典序最小的
if got[0] == "deepGlass" {
t.Fatal("首个应用应由 id 决定,不是名字")
}
}