-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable custom values for porter build command
- Loading branch information
1 parent
79ee7c3
commit 16041b1
Showing
15 changed files
with
392 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package buildkit | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestConvertMap(t *testing.T) { | ||
tt := []struct { | ||
desc string | ||
inp map[string]interface{} | ||
out map[string]string | ||
err bool | ||
}{ | ||
{ | ||
desc: "one pair", | ||
inp: map[string]interface{}{ | ||
"key": "value", | ||
}, | ||
out: map[string]string{ | ||
"key": "value", | ||
}, | ||
err: false, | ||
}, | ||
{ | ||
desc: "nested input", | ||
inp: map[string]interface{}{ | ||
"key": map[string]string{ | ||
"nestedKey": "value", | ||
}, | ||
}, | ||
out: map[string]string{ | ||
"key.nestedKey": "value", | ||
}, | ||
err: false, | ||
}, | ||
{ | ||
desc: "nested input", | ||
inp: map[string]interface{}{ | ||
"key1": map[string]interface{}{ | ||
"key2": map[string]string{ | ||
"key3": "value", | ||
}, | ||
}, | ||
}, | ||
out: map[string]string{ | ||
"key1.key2.key3": "value", | ||
}, | ||
err: false, | ||
}, | ||
{ | ||
desc: "multiple nested input", | ||
inp: map[string]interface{}{ | ||
"key11": map[string]interface{}{ | ||
"key12": map[string]string{ | ||
"key13": "value1", | ||
}, | ||
}, | ||
"key21": map[string]string{ | ||
"key22": "value2", | ||
}, | ||
}, | ||
out: map[string]string{ | ||
"key11.key12.key13": "value1", | ||
"key21.key22": "value2", | ||
}, | ||
err: false, | ||
}, | ||
{ | ||
desc: "empty interface value other than map[string]interface{}, map[string]string or string", | ||
inp: map[string]interface{}{ | ||
"a": 1, | ||
}, | ||
err: true, | ||
}, | ||
} | ||
|
||
for _, tc := range tt { | ||
t.Run(tc.desc, func(t *testing.T) { | ||
out, err := convertMap(tc.inp) | ||
if tc.err { | ||
require.Error(t, err) | ||
return | ||
} | ||
require.NoError(t, err) | ||
assert.Equal(t, out, tc.out) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package docker | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestConvertMap(t *testing.T) { | ||
tt := []struct { | ||
desc string | ||
inp map[string]interface{} | ||
out map[string]string | ||
err bool | ||
}{ | ||
{ | ||
desc: "one pair", | ||
inp: map[string]interface{}{ | ||
"key": "value", | ||
}, | ||
out: map[string]string{ | ||
"key": "value", | ||
}, | ||
err: false, | ||
}, | ||
{ | ||
desc: "nested input", | ||
inp: map[string]interface{}{ | ||
"key": map[string]string{ | ||
"nestedKey": "value", | ||
}, | ||
}, | ||
out: map[string]string{ | ||
"key.nestedKey": "value", | ||
}, | ||
err: false, | ||
}, | ||
{ | ||
desc: "nested input", | ||
inp: map[string]interface{}{ | ||
"key1": map[string]interface{}{ | ||
"key2": map[string]string{ | ||
"key3": "value", | ||
}, | ||
}, | ||
}, | ||
out: map[string]string{ | ||
"key1.key2.key3": "value", | ||
}, | ||
err: false, | ||
}, | ||
{ | ||
desc: "multiple nested input", | ||
inp: map[string]interface{}{ | ||
"key11": map[string]interface{}{ | ||
"key12": map[string]string{ | ||
"key13": "value1", | ||
}, | ||
}, | ||
"key21": map[string]string{ | ||
"key22": "value2", | ||
}, | ||
}, | ||
out: map[string]string{ | ||
"key11.key12.key13": "value1", | ||
"key21.key22": "value2", | ||
}, | ||
err: false, | ||
}, | ||
{ | ||
desc: "empty interface value other than map[string]interface{}, map[string]string or string", | ||
inp: map[string]interface{}{ | ||
"a": 1, | ||
}, | ||
err: true, | ||
}, | ||
} | ||
|
||
for _, tc := range tt { | ||
t.Run(tc.desc, func(t *testing.T) { | ||
out, err := convertMap(tc.inp) | ||
if tc.err { | ||
require.Error(t, err) | ||
return | ||
} | ||
require.NoError(t, err) | ||
assert.Equal(t, out, tc.out) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.