Commit a3466134 authored by Nick Thomas's avatar Nick Thomas 💃🏿

Allow network-sourced variables to specify that they should be files

parent 509eb5cd
......@@ -12,7 +12,7 @@ type BuildVariable struct {
Value string `json:"value"`
Public bool `json:"public"`
Internal bool `json:"-"`
File bool `json:"-"`
File bool `json:"file"`
}
type BuildVariables []BuildVariable
......
package common
import (
"github.com/stretchr/testify/assert"
"encoding/json"
"testing"
"github.com/stretchr/testify/assert"
)
func TestVariablesJSON(t *testing.T) {
var x BuildVariable
data := []byte(`{"key": "FOO", "value": "bar", "public": true, "internal": true, "file": true}`)
err := json.Unmarshal(data, &x)
assert.NoError(t, err)
assert.Equal(t, x.Key, "FOO")
assert.Equal(t, x.Value, "bar")
assert.Equal(t, x.Public, true)
assert.Equal(t, x.Internal, false) // cannot be set from the network
assert.Equal(t, x.File, true)
}
func TestVariableString(t *testing.T) {
v := BuildVariable{"key", "value", false, false, false}
assert.Equal(t, "key=value", v.String())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment