diff options
author | Matthew Holt <mholt@users.noreply.github.com> | 2019-06-18 15:43:51 -0600 |
---|---|---|
committer | Matthew Holt <mholt@users.noreply.github.com> | 2019-06-18 15:43:51 -0600 |
commit | 15647bdfb757ab7b1d1c77446a0707e49f31deb7 (patch) | |
tree | 1db7b1694d142a974e7fd6b444bfa65e3240ef4e /modules/caddyhttp/templates/tplcontext_test.go | |
parent | 2663dd176d38dfb929bcc478cac3913827f1246e (diff) |
templates: Remove context functions implemented by sprig
Diffstat (limited to 'modules/caddyhttp/templates/tplcontext_test.go')
-rw-r--r-- | modules/caddyhttp/templates/tplcontext_test.go | 131 |
1 files changed, 0 insertions, 131 deletions
diff --git a/modules/caddyhttp/templates/tplcontext_test.go b/modules/caddyhttp/templates/tplcontext_test.go index af4ad4e..efe5374 100644 --- a/modules/caddyhttp/templates/tplcontext_test.go +++ b/modules/caddyhttp/templates/tplcontext_test.go @@ -109,42 +109,6 @@ func TestCookieMultipleCookies(t *testing.T) { } } -func TestEnv(t *testing.T) { - context := getContextOrFail(t) - - name := "ENV_TEST_NAME" - testValue := "TEST_VALUE" - os.Setenv(name, testValue) - - notExisting := "ENV_TEST_NOT_EXISTING" - os.Unsetenv(notExisting) - - invalidName := "ENV_TEST_INVALID_NAME" - os.Setenv("="+invalidName, testValue) - - env := context.Env() - if value := env[name]; value != testValue { - t.Errorf("Expected env-variable %s value '%s', found '%s'", - name, testValue, value) - } - - if value, ok := env[notExisting]; ok { - t.Errorf("Expected empty env-variable %s, found '%s'", - notExisting, value) - } - - for k, v := range env { - if strings.Contains(k, invalidName) { - t.Errorf("Expected invalid name not to be included in Env %s, found in key '%s'", invalidName, k) - } - if strings.Contains(v, invalidName) { - t.Errorf("Expected invalid name not be be included in Env %s, found in value '%s'", invalidName, v) - } - } - - os.Unsetenv("=" + invalidName) -} - func TestIP(t *testing.T) { context := getContextOrFail(t) for i, test := range []struct { @@ -164,57 +128,6 @@ func TestIP(t *testing.T) { } } -func TestTruncate(t *testing.T) { - context := getContextOrFail(t) - - for i, test := range []struct { - input string - length int - expect string - }{ - { - input: "string", - length: 1, - expect: "s", - }, - { - input: "string", - length: 6, - expect: "string", - }, - { - input: "string", - length: 10, - expect: "string", - }, - { - input: "string", - length: 0, - expect: "", - }, - { - input: "string", - length: -5, - expect: "tring", - }, - { - input: "string", - length: -6, - expect: "string", - }, - { - input: "string", - length: -7, - expect: "string", - }, - } { - actual := context.Truncate(test.input, test.length) - if actual != test.expect { - t.Errorf("Test %d: Expected '%s' but got '%s'", i, test.expect, actual) - } - } -} - func TestStripHTML(t *testing.T) { context := getContextOrFail(t) @@ -260,50 +173,6 @@ func TestStripHTML(t *testing.T) { } } -func TestStripExt(t *testing.T) { - context := getContextOrFail(t) - tests := []struct { - input string - expect string - }{ - { - input: "", - expect: "", - }, - { - input: "file.ext", - expect: "file", - }, - { - input: "file", - expect: "file", - }, - { - input: "/file", - expect: "/file", - }, - { - input: "/file.ext", - expect: "/file", - }, - { - input: "/dir.ext/", - expect: "/dir.ext/", - }, - { - input: "/dir.ext/file.ext", - expect: "/dir.ext/file", - }, - } - - for i, test := range tests { - actual := context.StripExt(test.input) - if actual != test.expect { - t.Errorf("Test %d: Expected %s but got %s", i, test.expect, actual) - } - } -} - func TestFileListing(t *testing.T) { for i, test := range []struct { fileNames []string |