Skip to content

Commit

Permalink
made test pass
Browse files Browse the repository at this point in the history
  • Loading branch information
matryer committed Feb 24, 2023
1 parent e7ab51f commit a0027a5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 0 additions & 2 deletions render/example_golang.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"html/template"
"log"
"strings"

"github.com/pacedotdev/oto/parser"
Expand Down Expand Up @@ -32,7 +31,6 @@ func ObjectGolang(def parser.Definition, parentField *parser.Field, object *pars
continue
}
// normal field
log.Printf("%+v", field)
fmt.Fprintf(s, "%s: %v,", field.Name, jsonStr(field.Metadata["example"]))
}
fmt.Fprintf(s, strings.Repeat("\t", tabs+1))
Expand Down
12 changes: 7 additions & 5 deletions render/example_golang_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package render

import (
"os"
"log"
"strings"
"testing"

Expand All @@ -20,12 +20,14 @@ func TestExmapleGolang(t *testing.T) {
inputObject, err := def.Object(def.Services[0].Methods[0].InputObject.ObjectName)
is.NoErr(err) // get inputObject
example := ObjectGolang(def, nil, inputObject, 0)
err = os.WriteFile("./delete-me-example.go.notgo", []byte(example), 0666)
is.NoErr(err) // write file

// err = os.WriteFile("./delete-me-example.go.notgo", []byte(example), 0666)
// is.NoErr(err) // write file

log.Printf("### %s ###", example)

for _, should := range []string{
"// Package services contains services.",
"package services",
"OrderField: null",
} {
if !strings.Contains(string(example), should) {
t.Errorf("missing: %s", should)
Expand Down

0 comments on commit a0027a5

Please sign in to comment.