Skip to content

Commit

Permalink
test: @READ* in objectsPath not allowed; fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nxcc committed Jan 10, 2023
1 parent cfec0a7 commit ea8ef5c
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 28 deletions.
6 changes: 4 additions & 2 deletions tests/local/kustomize.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ objectsPath: objects
-- chart/a.cue --
package kube

objects: [{
obj: {
metadata: name: "dummy" // name and kind are
kind: "ConfigMap" // required by kustomize
data: aaa: string @readfile(file=trim)
}]
}

objects: [obj]

-- chart/file --
FILE
6 changes: 4 additions & 2 deletions tests/local/read-structured-all.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ objectsPath: objects
-- chart/a.cue --
package kube

objects: [{
obj: {
dir: {} @read(dir, data.env, data.yaml, data.json)
}]
}

objects: [obj]

-- chart/dir/a --
A
Expand Down
6 changes: 4 additions & 2 deletions tests/local/read-structured-dir.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ objectsPath: objects
-- chart/a.cue --
package kube

objects: [{
obj: {
dir: {} @read(dir)
}]
}

objects: [obj]

-- chart/dir/a --
A
Expand Down
6 changes: 4 additions & 2 deletions tests/local/read-structured-env.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ objectsPath: objects
-- chart/a.cue --
package kube

objects: [{
obj: {
dir: {} @read(data.env)
}]
}

objects: [obj]

-- chart/data.env --
c=data-c
Expand Down
6 changes: 4 additions & 2 deletions tests/local/read-structured-fail.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ objectsPath: objects
-- chart/a.cue --
package kube

objects: [{
obj: {
a: {} @read(data.yaml)
}]
}

objects: [obj]

-- chart/data.yaml --
a=b
Expand Down
6 changes: 4 additions & 2 deletions tests/local/read-structured-json.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ objectsPath: objects
-- chart/a.cue --
package kube

objects: [{
obj: {
dir: {} @read(data.json)
}]
}

objects: [obj]

-- chart/data.json --
{"g":{"k":{"l": "data-l","m": "data-m"}}}
Expand Down
6 changes: 4 additions & 2 deletions tests/local/read-structured-yaml.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ objectsPath: objects
-- chart/a.cue --
package kube

objects: [{
obj: {
dir: {} @read(data.yaml)
}]
}

objects: [obj]

-- chart/data.yaml --
g:
Expand Down
6 changes: 4 additions & 2 deletions tests/local/readfile-not-found.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ objectsPath: objects
-- chart/a.cue --
package kube

objects: [{
obj: {
b: string @readfile(no-such-file)
}]
}

objects: [obj]
12 changes: 8 additions & 4 deletions tests/local/readfile-sops.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,23 @@ objectsPath: objects
-- chart1/a.cue --
package kube

objects: [{
obj: {
secret: string @readfile(secret.txt=trim)
}]
}

objects: [obj]

-- chart2/cuegen.yaml --
objectsPath: objects

-- chart2/a.cue --
package kube

objects: [{
obj: {
secret: string @readfile(secret.txt=trim)
}]
}

objects: [obj]

-- keys.txt --
# * * * this key is just for testing, never use it for anything else * * *
Expand Down
12 changes: 8 additions & 4 deletions tests/local/readfile-trim-nl.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,23 @@ objectsPath: objects
-- chart1/a.cue --
package kube

objects: [{
obj: {
a: string @readfile(file=trim,file=trim,file=trim)
}]
}

objects: [obj]

-- chart2/cuegen.yaml --
objectsPath: objects

-- chart2/a.cue --
package kube

objects: [{
obj: {
b: string @readfile(file1=nl,file2=nl,file3=nl)
}]
}

objects: [obj]

-- chart1/file --
FILE1
Expand Down
12 changes: 8 additions & 4 deletions tests/local/readfile.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,23 @@ objectsPath: objects
-- chart1/a.cue --
package kube

objects: [{
obj: {
a: string @readfile(file1)
}]
}

objects: [obj]

-- chart2/cuegen.yaml --
objectsPath: objects

-- chart2/a.cue --
package kube

objects: [{
obj: {
b: string @readfile(file1,file2)
}]
}

objects: [obj]

-- chart1/file1 --
FILE-A
Expand Down

0 comments on commit ea8ef5c

Please sign in to comment.