~alazarte/cfgreader

ref: 52a1f1900e8a800e610e70c24f4e70d683d47578 cfgreader/unmarshaler_test.go -rw-r--r-- 661 bytes
52a1f190 — Alejandro Lazarte Initial commit 7 months ago
                                                                                
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
package cfgreader

import (
	"fmt"
	"os"
	"testing"
)

func TestInit(t *testing.T) {
	contents := `Pem=fullchainfile.pem
Sk=privkeyfile.pem
Handler.Name=someName
Handler.Path=/tmp
Handler.Type=type
`
	if err := os.WriteFile("test", []byte(contents), 0644); err != nil {
		t.Fatal(err)
	}
}
func TestHelloWorld(t *testing.T) {
	c := struct {
		Pem     string
		Sk      string
		Handler struct {
			Name string
			Path string
			Type string
		}
	}{}
	if err := FromFile("test", &c); err != nil {
		t.Fatal(err)
	}
	if fmt.Sprintf("%q", &c) != "&{\"fullchainfile.pem\" \"privkeyfile.pem\" {\"someName\" \"/tmp\" \"type\"}}" {
		t.Fatal("Not what I expected")
	}
}