sync: 同步 v1.0.4 并脱敏配置与镜像
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package batchmetadata
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestValidateCreation(t *testing.T) {
|
||||
for _, channel := range []string{Console, MiniProgram, API, System} {
|
||||
for _, mode := range []int{Single, Bulk} {
|
||||
if err := ValidateCreation(channel, mode); err != nil {
|
||||
t.Fatal(channel, mode, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, channel := range []string{"", Legacy} {
|
||||
if err := ValidateCreation(channel, Single); err == nil {
|
||||
t.Fatal("missing new batch attribution accepted", channel)
|
||||
}
|
||||
}
|
||||
if ValidateCreation("worker", Single) == nil {
|
||||
t.Fatal("invalid source accepted")
|
||||
}
|
||||
for _, mode := range []int{-1, Unknown, 3} {
|
||||
if ValidateCreation(Console, mode) == nil {
|
||||
t.Fatal("invalid new execution size accepted", mode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestMetadata(t *testing.T) {
|
||||
if NormalizeMode(0) != Unknown {
|
||||
t.Fatal("unspecified entry mode must remain unknown")
|
||||
}
|
||||
if NormalizeMode(Single) != Single {
|
||||
t.Fatal("single entry mode lost")
|
||||
}
|
||||
if NormalizeMode(Bulk) != Bulk {
|
||||
t.Fatal("bulk entry mode lost")
|
||||
}
|
||||
if NormalizeMode(99) != Unknown {
|
||||
t.Fatal("invalid entry mode accepted")
|
||||
}
|
||||
for _, c := range []string{Console, MiniProgram, API, System, Legacy} {
|
||||
if Channel(c) != c {
|
||||
t.Fatal(c)
|
||||
}
|
||||
}
|
||||
if Channel("worker") != Legacy || Channel("") != Legacy {
|
||||
t.Fatal("unknown source was attributed")
|
||||
}
|
||||
if ValidMode(-1) || ValidMode(3) {
|
||||
t.Fatal("invalid mode accepted")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user