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.
- Loading branch information
1 parent
d9e5f78
commit 3a96684
Showing
4 changed files
with
88 additions
and
14 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
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
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
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,37 @@ | ||
package gomplate | ||
|
||
import ( | ||
"testing" | ||
|
||
_ "github.com/flanksource/gomplate/v3/js" | ||
_ "github.com/robertkrimen/otto/underscore" | ||
) | ||
|
||
func Test_hashFunction(t *testing.T) { | ||
type args struct { | ||
env map[string]any | ||
expr string | ||
} | ||
|
||
tests := []struct { | ||
name string | ||
args args | ||
want string | ||
}{ | ||
{ | ||
name: "simple", | ||
args: args{ | ||
expr: "{{.name}}{{.age}}", | ||
env: map[string]any{"age": 19, "name": "james"}, | ||
}, | ||
want: "age-name--{{.name}}{{.age}}", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := cacheKey(tt.args.env, tt.args.expr); got != tt.want { | ||
t.Errorf("hashFunction() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |