Skip to content
This repository was archived by the owner on Aug 22, 2020. It is now read-only.

Update Travis Go versions to 1.12 and 1.13 #23

Merged
merged 1 commit into from
Dec 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ language: go
go_import_path: github.com/docker-library/go-dockerlibrary

go:
- 1.11.x
- 1.10.x
- 1.13.x
- 1.12.x

os:
- linux
Expand Down
37 changes: 17 additions & 20 deletions pkg/templatelib/lib_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package templatelib_test

import (
"strings"
"testing"
"text/template"
"unsafe"
Expand All @@ -11,35 +12,31 @@ import (
func TestTernaryPanic(t *testing.T) {
// one of the only places template.IsTrue will return "false" for the "ok" value is an UnsafePointer (hence this test)

defer func() {
if r := recover(); r == nil {
t.Errorf("Expected panic, executed successfully instead")
} else if errText, ok := r.(string); !ok || errText != `template.IsTrue(<nil>) says things are NOT OK` {
t.Errorf("Unexpected panic: %v", errText)
}
}()

tmpl, err := template.New("unsafe-pointer").Funcs(templatelib.FuncMap).Parse(`{{ ternary "true" "false" . }}`)
if err != nil {
t.Errorf("Unexpected error: %v", err)
}

err = tmpl.Execute(nil, unsafe.Pointer(uintptr(0)))
if err != nil {
t.Errorf("Expected panic, got error instead: %v", err)
if err == nil {
t.Errorf("Expected error, executed successfully instead")
}
if !strings.HasSuffix(err.Error(), `template.IsTrue(<nil>) says things are NOT OK`) {
t.Errorf("Expected specific error, got: %v", err)
}
}

func TestJoinPanic(t *testing.T) {
defer func() {
if r := recover(); r == nil {
t.Errorf("Expected panic, executed successfully instead")
} else if errText, ok := r.(string); !ok || errText != `"join" requires at least one argument` {
t.Errorf("Unexpected panic: %v", r)
}
}()

tmpl, err := template.New("join-no-arg").Funcs(templatelib.FuncMap).Parse(`{{ join }}`)
if err != nil {
t.Errorf("Unexpected error: %v", err)
}

err = tmpl.Execute(nil, nil)
if err != nil {
t.Errorf("Expected panic, got error instead: %v", err)
if err == nil {
t.Errorf("Expected error, executed successfully instead")
}
if !strings.HasSuffix(err.Error(), `"join" requires at least one argument`) {
t.Errorf("Expected specific error, got: %v", err)
}
}