github.com/drone/runner-go@v1.12.0/manifest/env_test.go (about) 1 // Copyright 2019 Drone.IO Inc. All rights reserved. 2 // Use of this source code is governed by the Polyform License 3 // that can be found in the LICENSE file. 4 5 package manifest 6 7 import ( 8 "testing" 9 10 "github.com/buildkite/yaml" 11 ) 12 13 func TestEnv(t *testing.T) { 14 tests := []struct { 15 yaml string 16 value string 17 from string 18 }{ 19 { 20 yaml: "bar", 21 value: "bar", 22 }, 23 { 24 yaml: "from_secret: username", 25 from: "username", 26 }, 27 } 28 for _, test := range tests { 29 in := []byte(test.yaml) 30 out := new(Variable) 31 err := yaml.Unmarshal(in, out) 32 if err != nil { 33 t.Error(err) 34 return 35 } 36 if got, want := out.Value, test.value; got != want { 37 t.Errorf("Want variable value %q, got %q", want, got) 38 } 39 if got, want := out.Secret, test.from; got != want { 40 t.Errorf("Want variable from_secret %q, got %q", want, got) 41 } 42 } 43 }