Skip to content

Commit 8f1063b

Browse files
committed
refactor: update tests after pkg/ refactoring
1 parent 9402bb8 commit 8f1063b

File tree

60 files changed

+1428
-13
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1428
-13
lines changed

Makefile

+7-3
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,26 @@ generate-schema: ## Generate schema
2121
.PHONY: write-fixtures
2222
write-fixtures: ## Write new test fixtures
2323
@rm -f ./fixtures/*.out.yaml ./fixtures/*.validator.json
24-
@WRITE_FIXTURES=1 go test -count=1 .
24+
@WRITE_FIXTURES=1 go test -count=1 ./pkg/blueprint/
2525

2626
.PHONY: pkg-go-dev-update
2727
pkg-go-dev-update: ## Schedule https://pkg.go.dev/github.com/osbuild/blueprint-schema for update
2828
GOPROXY=https://proxy.golang.org go get github.com/osbuild/blueprint-schema
2929

3030
.PHONY: test
3131
test: ## Run all tests
32-
@go test -count=1 .
32+
@go test -count=1 ./...
3333

3434
# Option --without-id is a workaround for VSCode: https://github.com/sourcemeta/jsonschema/blob/main/docs/bundle.markdown
3535
$(SCHEMA_DST): $(SCHEMA_SRC) Makefile ## Build the schema from schema/*.schema.yaml files
3636
jsonschema bundle schema/blueprint.schema.yaml --verbose --resolve schema/ --extension schema.yaml --without-id > $@
3737

38+
.PHONY: schema-check
39+
schema-check: ## Check input schema files against JSON Metaschema
40+
jsonschema metaschema -e schema.yaml schema/
41+
3842
.PHONY: schema-fmt
39-
schema-fmt: $(SCHEMA_DST) ## Format the schema against JSON Metaschema
43+
schema-fmt: $(SCHEMA_DST) ## Lint and format the bundled schema
4044
jsonschema lint --fix $(SCHEMA_DST)
4145
jsonschema fmt $(SCHEMA_DST)
4246

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
accounts:
2+
groups:
3+
- name: -names-starting-with-dash
4+
- name: all-names-longer-than-256-characters-------------------------------------- -------------------------------------------------------------------------- -------------------------------------------------------------------------- --------------------------------------------------------------------------
5+
- name: names-with-diakritics-žluťoučký-kůň
6+
- name: names with spaces
7+
- name: gid-0
8+
name: 'Blueprint example: accounts'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
{
2+
"valid": false,
3+
"keywordLocation": "",
4+
"instanceLocation": "",
5+
"errors": [
6+
{
7+
"valid": false,
8+
"keywordLocation": "/properties/accounts/oneOf",
9+
"instanceLocation": "/accounts",
10+
"errors": [
11+
{
12+
"valid": false,
13+
"keywordLocation": "/properties/accounts/oneOf/1/type",
14+
"instanceLocation": "/accounts",
15+
"error": "got object, want null"
16+
},
17+
{
18+
"valid": false,
19+
"keywordLocation": "/properties/accounts/oneOf/0/$ref/properties/groups/oneOf",
20+
"instanceLocation": "/accounts/groups",
21+
"errors": [
22+
{
23+
"valid": false,
24+
"keywordLocation": "/properties/accounts/oneOf/0/$ref/properties/groups/oneOf/0",
25+
"instanceLocation": "/accounts/groups",
26+
"errors": [
27+
{
28+
"valid": false,
29+
"keywordLocation": "/properties/accounts/oneOf/0/$ref/properties/groups/oneOf/0/items/$ref/properties/name/pattern",
30+
"instanceLocation": "/accounts/groups/0/name",
31+
"error": "'-names-starting-with-dash' does not match pattern '^[a-zA-Z0-9_.][a-zA-Z0-9_.$-]*$'"
32+
},
33+
{
34+
"valid": false,
35+
"keywordLocation": "/properties/accounts/oneOf/0/$ref/properties/groups/oneOf/0/items/$ref",
36+
"instanceLocation": "/accounts/groups/1",
37+
"errors": [
38+
{
39+
"valid": false,
40+
"keywordLocation": "/properties/accounts/oneOf/0/$ref/properties/groups/oneOf/0/items/$ref/properties/name/maxLength",
41+
"instanceLocation": "/accounts/groups/1/name",
42+
"error": "maxLength: got 299, want 256"
43+
},
44+
{
45+
"valid": false,
46+
"keywordLocation": "/properties/accounts/oneOf/0/$ref/properties/groups/oneOf/0/items/$ref/properties/name/pattern",
47+
"instanceLocation": "/accounts/groups/1/name",
48+
"error": "'^[a-zA-Z0-9_.][a-zA-Z0-9_.$-]*$' does not match pattern 'all-names-longer-than-256-characters-------------------------------------- -------------------------------------------------------------------------- -------------------------------------------------------------------------- --------------------------------------------------------------------------'"
49+
}
50+
]
51+
},
52+
{
53+
"valid": false,
54+
"keywordLocation": "/properties/accounts/oneOf/0/$ref/properties/groups/oneOf/0/items/$ref/properties/name/pattern",
55+
"instanceLocation": "/accounts/groups/2/name",
56+
"error": "'^[a-zA-Z0-9_.][a-zA-Z0-9_.$-]*$' does not match pattern 'names-with-diakritics-žluťoučký-kůň'"
57+
},
58+
{
59+
"valid": false,
60+
"keywordLocation": "/properties/accounts/oneOf/0/$ref/properties/groups/oneOf/0/items/$ref/properties/name/pattern",
61+
"instanceLocation": "/accounts/groups/3/name",
62+
"error": "'^[a-zA-Z0-9_.][a-zA-Z0-9_.$-]*$' does not match pattern 'names with spaces'"
63+
},
64+
{
65+
"valid": false,
66+
"keywordLocation": "/properties/accounts/oneOf/0/$ref/properties/groups/oneOf/0/items/$ref/additionalProperties",
67+
"instanceLocation": "/accounts/groups/4",
68+
"error": "additional properties 'uid' not allowed"
69+
}
70+
]
71+
},
72+
{
73+
"valid": false,
74+
"keywordLocation": "/properties/accounts/oneOf/0/$ref/properties/groups/oneOf/1/type",
75+
"instanceLocation": "/accounts/groups",
76+
"error": "got array, want null"
77+
}
78+
]
79+
}
80+
]
81+
}
82+
]
83+
}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
accounts:
2+
users:
3+
- expires: "0001-01-01"
4+
name: -names-starting-with-dash
5+
- expires: "0001-01-01"
6+
name: all-names-longer-than-256-characters-------------------------------------- -------------------------------------------------------------------------- -------------------------------------------------------------------------- --------------------------------------------------------------------------
7+
- expires: "0001-01-01"
8+
name: names-with-diakritics-žluťoučký-kůň
9+
- expires: "0001-01-01"
10+
name: names with spaces
11+
- expires: "0001-01-01"
12+
name: uid-0
13+
name: 'Blueprint example: accounts'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
{
2+
"valid": false,
3+
"keywordLocation": "",
4+
"instanceLocation": "",
5+
"errors": [
6+
{
7+
"valid": false,
8+
"keywordLocation": "/properties/accounts/oneOf",
9+
"instanceLocation": "/accounts",
10+
"errors": [
11+
{
12+
"valid": false,
13+
"keywordLocation": "/properties/accounts/oneOf/1/type",
14+
"instanceLocation": "/accounts",
15+
"error": "got object, want null"
16+
},
17+
{
18+
"valid": false,
19+
"keywordLocation": "/properties/accounts/oneOf/0/$ref/properties/users/oneOf",
20+
"instanceLocation": "/accounts/users",
21+
"errors": [
22+
{
23+
"valid": false,
24+
"keywordLocation": "/properties/accounts/oneOf/0/$ref/properties/users/oneOf/0",
25+
"instanceLocation": "/accounts/users",
26+
"errors": [
27+
{
28+
"valid": false,
29+
"keywordLocation": "/properties/accounts/oneOf/0/$ref/properties/users/oneOf/0/items/$ref/properties/name/pattern",
30+
"instanceLocation": "/accounts/users/0/name",
31+
"error": "'-names-starting-with-dash' does not match pattern '^[a-zA-Z0-9_.][a-zA-Z0-9_.$-]*$'"
32+
},
33+
{
34+
"valid": false,
35+
"keywordLocation": "/properties/accounts/oneOf/0/$ref/properties/users/oneOf/0/items/$ref",
36+
"instanceLocation": "/accounts/users/1",
37+
"errors": [
38+
{
39+
"valid": false,
40+
"keywordLocation": "/properties/accounts/oneOf/0/$ref/properties/users/oneOf/0/items/$ref/properties/name/maxLength",
41+
"instanceLocation": "/accounts/users/1/name",
42+
"error": "maxLength: got 299, want 256"
43+
},
44+
{
45+
"valid": false,
46+
"keywordLocation": "/properties/accounts/oneOf/0/$ref/properties/users/oneOf/0/items/$ref/properties/name/pattern",
47+
"instanceLocation": "/accounts/users/1/name",
48+
"error": "'^[a-zA-Z0-9_.][a-zA-Z0-9_.$-]*$' does not match pattern 'all-names-longer-than-256-characters-------------------------------------- -------------------------------------------------------------------------- -------------------------------------------------------------------------- --------------------------------------------------------------------------'"
49+
}
50+
]
51+
},
52+
{
53+
"valid": false,
54+
"keywordLocation": "/properties/accounts/oneOf/0/$ref/properties/users/oneOf/0/items/$ref/properties/name/pattern",
55+
"instanceLocation": "/accounts/users/2/name",
56+
"error": "'^[a-zA-Z0-9_.][a-zA-Z0-9_.$-]*$' does not match pattern 'names-with-diakritics-žluťoučký-kůň'"
57+
},
58+
{
59+
"valid": false,
60+
"keywordLocation": "/properties/accounts/oneOf/0/$ref/properties/users/oneOf/0/items/$ref/properties/name/pattern",
61+
"instanceLocation": "/accounts/users/3/name",
62+
"error": "'^[a-zA-Z0-9_.][a-zA-Z0-9_.$-]*$' does not match pattern 'names with spaces'"
63+
},
64+
{
65+
"valid": false,
66+
"keywordLocation": "/properties/accounts/oneOf/0/$ref/properties/users/oneOf/0/items/$ref/properties/uid/minimum",
67+
"instanceLocation": "/accounts/users/4/uid",
68+
"error": "minimum: got 0, want 1"
69+
}
70+
]
71+
},
72+
{
73+
"valid": false,
74+
"keywordLocation": "/properties/accounts/oneOf/0/$ref/properties/users/oneOf/1/type",
75+
"instanceLocation": "/accounts/users",
76+
"error": "got array, want null"
77+
}
78+
]
79+
}
80+
]
81+
}
82+
]
83+
}

fixtures/invalid-dnf-sources.out.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
dnf:
2+
repositories:
3+
- base_urls:
4+
- https://mirror.fedora.example.com/fedora/$releasever/$basearch/cisco-openh264
5+
id: fedora-cisco-openh264
6+
metalink: https://mirrors.fedoraproject.org/metalink?repo=fedora-cisco-openh264-$releasever&arch=$basearch
7+
name: 'Blueprint example: DNF'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"valid": false,
3+
"keywordLocation": "",
4+
"instanceLocation": "",
5+
"errors": [
6+
{
7+
"valid": false,
8+
"keywordLocation": "/properties/dnf/oneOf",
9+
"instanceLocation": "/dnf",
10+
"errors": [
11+
{
12+
"valid": false,
13+
"keywordLocation": "/properties/dnf/oneOf/1/type",
14+
"instanceLocation": "/dnf",
15+
"error": "got object, want null"
16+
},
17+
{
18+
"valid": false,
19+
"keywordLocation": "/properties/dnf/oneOf/0/$ref/properties/repositories/oneOf",
20+
"instanceLocation": "/dnf/repositories",
21+
"errors": [
22+
{
23+
"valid": false,
24+
"keywordLocation": "/properties/dnf/oneOf/0/$ref/properties/repositories/oneOf/1/type",
25+
"instanceLocation": "/dnf/repositories",
26+
"error": "got array, want null"
27+
},
28+
{
29+
"valid": false,
30+
"keywordLocation": "/properties/dnf/oneOf/0/$ref/properties/repositories/oneOf/0/items/$ref/oneOf",
31+
"instanceLocation": "/dnf/repositories/0",
32+
"error": "oneOf failed, subschemas 0, 2 matched"
33+
}
34+
]
35+
}
36+
]
37+
}
38+
]
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name: Firewall example - missing from
2+
network:
3+
firewall:
4+
services:
5+
- enabled: null
6+
to: 1303
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"valid": false,
3+
"keywordLocation": "",
4+
"instanceLocation": "",
5+
"errors": [
6+
{
7+
"valid": false,
8+
"keywordLocation": "/properties/network/oneOf",
9+
"instanceLocation": "/network",
10+
"errors": [
11+
{
12+
"valid": false,
13+
"keywordLocation": "/properties/network/oneOf/1/type",
14+
"instanceLocation": "/network",
15+
"error": "got object, want null"
16+
},
17+
{
18+
"valid": false,
19+
"keywordLocation": "/properties/network/oneOf/0/$ref/properties/firewall/$ref/properties/services/oneOf",
20+
"instanceLocation": "/network/firewall/services",
21+
"errors": [
22+
{
23+
"valid": false,
24+
"keywordLocation": "/properties/network/oneOf/0/$ref/properties/firewall/$ref/properties/services/oneOf/1/type",
25+
"instanceLocation": "/network/firewall/services",
26+
"error": "got array, want null"
27+
},
28+
{
29+
"valid": false,
30+
"keywordLocation": "/properties/network/oneOf/0/$ref/properties/firewall/$ref/properties/services/oneOf/0/items/oneOf",
31+
"instanceLocation": "/network/firewall/services/0",
32+
"errors": [
33+
{
34+
"valid": false,
35+
"keywordLocation": "/properties/network/oneOf/0/$ref/properties/firewall/$ref/properties/services/oneOf/0/items/oneOf/0/required",
36+
"instanceLocation": "/network/firewall/services/0",
37+
"error": "missing property 'service'"
38+
},
39+
{
40+
"valid": false,
41+
"keywordLocation": "/properties/network/oneOf/0/$ref/properties/firewall/$ref/properties/services/oneOf/0/items/oneOf/1/required",
42+
"instanceLocation": "/network/firewall/services/0",
43+
"error": "missing property 'port'"
44+
},
45+
{
46+
"valid": false,
47+
"keywordLocation": "/properties/network/oneOf/0/$ref/properties/firewall/$ref/properties/services/oneOf/0/items/oneOf/2/required",
48+
"instanceLocation": "/network/firewall/services/0",
49+
"error": "missing property 'from'"
50+
}
51+
]
52+
}
53+
]
54+
}
55+
]
56+
}
57+
]
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name: Firewall example - missing to
2+
network:
3+
firewall:
4+
services:
5+
- enabled: null
6+
from: 60000
7+
protocol: udp

0 commit comments

Comments
 (0)