MCPcopy Index your code
hub / github.com/koding/kite / TestGetQueryKey

Function TestGetQueryKey

kontrol/kontrol_test.go:620–660  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

618}
619
620func TestGetQueryKey(t *testing.T) {
621 // This query is valid because there are no gaps between query fields.
622 q := &protocol.KontrolQuery{
623 Username: "cenk",
624 Environment: "production",
625 }
626 key, err := GetQueryKey(q)
627 if err != nil {
628 t.Errorf(err.Error())
629 }
630 if key != "/cenk/production" {
631 t.Errorf("Unexpected key: %s", key)
632 }
633
634 // This is wrong because Environment field is empty.
635 // We can't make a query on etcd because wildcards are not allowed in paths.
636 q = &protocol.KontrolQuery{
637 Username: "cenk",
638 Name: "fs",
639 }
640 key, err = GetQueryKey(q)
641 if err == nil {
642 t.Errorf("Error is expected")
643 }
644 if key != "" {
645 t.Errorf("Key is not expected: %s", key)
646 }
647
648 // This is also wrong becaus each query must have a non-empty username field.
649 q = &protocol.KontrolQuery{
650 Environment: "production",
651 Name: "fs",
652 }
653 key, err = GetQueryKey(q)
654 if err == nil {
655 t.Errorf("Error is expected")
656 }
657 if key != "" {
658 t.Errorf("Key is not expected: %s", key)
659 }
660}
661
662func TestKontrolMultiKey(t *testing.T) {
663 if storage := os.Getenv("KONTROL_STORAGE"); storage != "postgres" {

Callers

nothing calls this directly

Calls 2

GetQueryKeyFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected