File: values_test.go

package info (click to toggle)
golang-github-smallstep-certificates 0.20.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 23,144 kB
  • sloc: sh: 278; makefile: 170
file content (52 lines) | stat: -rw-r--r-- 1,288 bytes parent folder | download | duplicates (2)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package templates

import (
	"reflect"
	"testing"
)

func TestDefaultTemplates(t *testing.T) {
	sshTemplates := DefaultSSHTemplates
	sshTemplatesData := DefaultSSHTemplateData
	t.Cleanup(func() {
		DefaultSSHTemplates = sshTemplates
		DefaultSSHTemplateData = sshTemplatesData
	})

	DefaultSSHTemplates = SSHTemplates{
		User: []Template{
			{Name: "foo.tpl", Type: Snippet, TemplatePath: "templates/ssh/foo.tpl", Path: "/tmp/foo", Comment: "#"},
		},
		Host: []Template{
			{Name: "bar.tpl", Type: Snippet, TemplatePath: "templates/ssh/bar.tpl", Path: "/tmp/bar", Comment: "#"},
		},
	}
	DefaultSSHTemplateData = map[string]string{
		"foo.tpl": "foo",
		"bar.tpl": "bar",
	}

	tests := []struct {
		name string
		want *Templates
	}{
		{"ok", &Templates{
			SSH: &SSHTemplates{
				User: []Template{
					{Name: "foo.tpl", Type: Snippet, Content: []byte("foo"), Path: "/tmp/foo", Comment: "#"},
				},
				Host: []Template{
					{Name: "bar.tpl", Type: Snippet, Content: []byte("bar"), Path: "/tmp/bar", Comment: "#"},
				},
			},
			Data: map[string]interface{}{},
		}},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := DefaultTemplates(); !reflect.DeepEqual(got, tt.want) {
				t.Errorf("DefaultTemplates() = %v, want %v", got, tt.want)
			}
		})
	}
}