query_test.go 670 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package utils_test
  2. import (
  3. "encoding/json"
  4. "testing"
  5. "github.com/porter-dev/porter/internal/templater"
  6. "github.com/porter-dev/porter/internal/templater/utils"
  7. )
  8. type testType struct {
  9. Value interface{} `json:"value,omitempty"`
  10. }
  11. func TestQueryValues(t *testing.T) {
  12. vals := map[string]interface{}{
  13. "testing": map[string]interface{}{
  14. "hello": "there",
  15. },
  16. }
  17. queries := make([]*templater.TemplateReaderQuery, 0)
  18. query, _ := utils.NewQuery("test", `{ .testing }`)
  19. queries = append(queries, query)
  20. res, _ := utils.QueryValues(vals, queries)
  21. test := &testType{
  22. Value: res["test"],
  23. }
  24. bytes, _ := json.Marshal(test)
  25. t.Errorf(string(bytes))
  26. }