summaryrefslogtreecommitdiff
path: root/internal/tests/integration/datasources_env_test.go
blob: 81aad3947605bd6423972205f06bd5fb62dd648a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package integration

import (
	"testing"
)

func TestDatasources_Env(t *testing.T) {
	o, e, err := cmd(t, "-d", "foo=env:FOO", "-i", `{{ ds "foo" }}`).
		withEnv("HELLO_WORLD", "hello world").
		withEnv("HELLO_UNIVERSE", "hello universe").
		withEnv("FOO", "bar").
		withEnv("foo", "baz").
		run()
	// Windows envvars are case-insensitive
	if isWindows {
		assertSuccess(t, o, e, err, "baz")
	} else {
		assertSuccess(t, o, e, err, "bar")
	}

	o, e, err = cmd(t,
		"-d", "foo=env:///foo", "-i", `{{ ds "foo" }}`).
		withEnv("HELLO_WORLD", "hello world").
		withEnv("HELLO_UNIVERSE", "hello universe").
		withEnv("FOO", "bar").
		withEnv("foo", "baz").
		run()
	assertSuccess(t, o, e, err, "baz")

	o, e, err = cmd(t, "-d", "e=env:json_value?type=application/json",
		"-i", `{{ (ds "e").value}}`).
		withEnv("json_value", `{"value":"corge"}`).
		run()
	assertSuccess(t, o, e, err, "corge")
}