-
Notifications
You must be signed in to change notification settings - Fork 0
/
air_test.go
82 lines (71 loc) · 1.71 KB
/
air_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package air_parser
import (
"testing"
)
func TestValidAirValues(t *testing.T) {
cases := make(map[string]Air)
cases["urn:air:sd1:model:civitai:2421@43533:layer.safetensors"] = Air{
Ecosystem: "sd1",
Type: "model",
Source: "civitai",
Id: "2421",
Version: "43533",
Layer: "layer",
Format: "safetensors",
}
cases["urn:air:sd1:model:civitai:2421@43533:layer"] = Air{
Ecosystem: "sd1",
Type: "model",
Source: "civitai",
Id: "2421",
Version: "43533",
Layer: "layer",
}
cases["urn:air:sd1:model:civitai:2421@43533"] = Air{
Ecosystem: "sd1",
Type: "model",
Source: "civitai",
Id: "2421",
Version: "43533",
}
cases["urn:air:sd1:model:civitai:2421"] = Air{
Ecosystem: "sd1",
Type: "model",
Source: "civitai",
Id: "2421",
}
cases["urn:air:sd1:model:civitai:2421:layer"] = Air{
Ecosystem: "sd1",
Type: "model",
Source: "civitai",
Id: "2421",
Layer: "layer",
}
cases["urn:air:sd1:model:civitai:2421:layer.safetensors"] = Air{
Ecosystem: "sd1",
Type: "model",
Source: "civitai",
Id: "2421",
Layer: "layer",
Format: "safetensors",
}
cases["urn:air:sd1:model:civitai:2421.safetensors"] = Air{
Ecosystem: "sd1",
Type: "model",
Source: "civitai",
Id: "2421",
Format: "safetensors",
}
for urn, expectedResult := range cases {
parsedResult, err := NewAirFromString(urn)
if err != nil {
panic(err)
}
if *parsedResult != expectedResult {
t.Fatalf("expected: %v got: %v", expectedResult, parsedResult)
}
if parsedResult.Urn() != urn {
t.Fatalf("urn mismatch. expect: '%s' got '%s'", urn, parsedResult.Urn())
}
}
}