query_test.go 547 B

123456789101112131415161718192021222324252627
  1. package prom
  2. import "testing"
  3. func TestWarningsFrom(t *testing.T) {
  4. var results interface{}
  5. results = map[string]interface{}{
  6. "status": "success",
  7. "warnings": []string{
  8. "Warning #1",
  9. "Warning #2",
  10. },
  11. }
  12. warnings := warningsFrom(results)
  13. if len(warnings) != 2 {
  14. t.Errorf("Unexpected warnings length: %d, Expected 2.", len(warnings))
  15. }
  16. if warnings[0] != "Warning #1" {
  17. t.Errorf("Unexpected first warning: %s", warnings[0])
  18. }
  19. if warnings[1] != "Warning #2" {
  20. t.Errorf("Unexpected second warning: %s", warnings[1])
  21. }
  22. }