Some betterment of things

This commit is contained in:
Olivier 2016-12-14 09:55:09 -05:00
parent a54632176b
commit c5811d75b7
No known key found for this signature in database
GPG key ID: 1A9FE7C1DFF65CB0
10 changed files with 115 additions and 50 deletions

43
jkl_test.go Normal file
View file

@ -0,0 +1,43 @@
package jkl
import (
"encoding/json"
"fmt"
"os"
"testing"
"text/template"
)
func TestUnmarshalProjects(t *testing.T) {
f, err := os.Open("projects.json")
if err != nil {
t.Error(err)
}
dec := json.NewDecoder(f)
x := struct{ Projects []Project }{}
err = dec.Decode(&x)
if err != nil {
t.Error(err)
}
for _, p := range x.Projects {
for _, it := range p.IssueTypes {
for sn, f := range it.Fields {
fmt.Println(it.Name, sn, f.Name, f.Required, f.Schema.Type)
}
}
}
}
type TestType struct {
Field string
}
func (t *TestType) String() string {
return t.Field
}
func TestStringerInTemplate(t *testing.T) {
x := template.Must(template.New("stuff").Parse("{{.}}"))
x.Execute(os.Stdout, &TestType{"This works"})
}