forked from hairyhenderson/gomplate
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add test case with time.Time in struct
- Loading branch information
1 parent
3694961
commit 329f9fe
Showing
2 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package gomplate_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/flanksource/gomplate/v3" | ||
) | ||
|
||
// var x = map[string]any { | ||
// "sslAge": 7010490606167092, | ||
// "json": map[string]any{}, | ||
// "content": "", | ||
// "headers": map[string]interface {} ["Content-Type": *(*interface {})(0xc01d21a508), | ||
// "Content-Length": *(*interface {})(0xc01d21a518), | ||
// "Access-Control-Allow-Origin": *(*interface {})(0xc01d21a528), | ||
// "Access-Control-Allow-Credentials": *(*interface {})(0xc01d21a538), | ||
// "Strict-Transport-Security": *(*interface {})(0xc01d21a548), | ||
// "Date": *(*interface {})(0xc01d21a558), | ||
// }, | ||
// "canary": map[string]interface {} ["name": *(*interface {})(0xc01d21a1a8), "namespace": *(*interface {})(0xc01d21a1b8), "labels": *(*interface {})(0xc01d21a1c8), "id": *(*interface {})(0xc01d21a1d8), ], | ||
// "check": 7010490606167092, | ||
// "duration": 702, | ||
// "results": map[string]any{"code": 200, "elapsed": 702296127} | ||
|
||
func TestMa(t *testing.T) { | ||
env := map[string]any{ | ||
"code": "200", | ||
"sslAge": "true", | ||
"check": map[string]any{ | ||
"name": "http-expr-tests", | ||
"id": "018c0096-81c2-7e7d-b324-157d2172c547", | ||
"description": "", | ||
"labels": map[string]any{}, | ||
"endpoint": "https://httpbin.demo.aws.flanksource.com/status/200", | ||
}, | ||
"duration": 702, | ||
"results": map[string]any{"code": 200, "elapsed": 702296127}, | ||
} | ||
|
||
for i := 0; i < 10000; i++ { | ||
_, err := gomplate.RunTemplate(env, gomplate.Template{Expression: `string(code) + " should be 500"`}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
if _, ok := env["check"].(map[string]any); !ok { | ||
t.Logf("Of type %T", env["check"]) | ||
t.Fail() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters