1
+ package hocon
2
+
3
+ import (
4
+ "encoding/json"
5
+ "github.com/falcosecurity/kilt/pkg/kilt"
6
+ "github.com/stretchr/testify/assert"
7
+ "io/ioutil"
8
+ "testing"
9
+ )
10
+
11
+ func TestSimpleRuntime (t * testing.T ) {
12
+ targetInfoString , _ := ioutil .ReadFile ("./fixtures/input.json" )
13
+ definitionString , _ := ioutil .ReadFile ("./fixtures/kilt.cfg" )
14
+ k := NewKiltHocon (string (definitionString ))
15
+ info := new (kilt.TargetInfo )
16
+ _ = json .Unmarshal (targetInfoString , info )
17
+ r , _ := k .Runtime (info )
18
+
19
+ assert .Equal (t , 1 , len (r .Uploads ), "expected 1 executable" )
20
+ assert .Equal (t , "https://storage.googleapis.com/kubernetes-release/release/v1.19.0/bin/linux/amd64/" ,
21
+ r .Uploads [0 ].Payload .Contents )
22
+ assert .Equal (t , kilt .URL , r .Uploads [0 ].Payload .Type )
23
+
24
+ assert .Equal (t , 1 , len (r .Executables ))
25
+ assert .Equal (t , "/bin/kubectl" , r .Executables [0 ].Run [0 ])
26
+ }
27
+
28
+ func TestSimpleBuild (t * testing.T ) {
29
+ targetInfoString , _ := ioutil .ReadFile ("./fixtures/input.json" )
30
+ definitionString , _ := ioutil .ReadFile ("./fixtures/kilt.cfg" )
31
+ k := NewKiltHocon (string (definitionString ))
32
+ info := new (kilt.TargetInfo )
33
+ _ = json .Unmarshal (targetInfoString , info )
34
+ b , _ := k .Build (info )
35
+
36
+ assert .Equal (t , "busybox:latest" , b .Image )
37
+ assert .Equal (t , "/falco/pdig" , b .EntryPoint [0 ])
38
+ assert .Equal (t , "true" , b .EnvironmentVariables ["TEST" ])
39
+ assert .Equal (t , 1 , len (b .Resources ))
40
+ }
0 commit comments