app_id_test.go 972 B

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright 2011 Google Inc. All Rights Reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. package internal
  5. import (
  6. "testing"
  7. )
  8. func TestAppIDParsing(t *testing.T) {
  9. testCases := []struct {
  10. in string
  11. partition, domain, displayID string
  12. }{
  13. {"simple-app-id", "", "", "simple-app-id"},
  14. {"domain.com:domain-app-id", "", "domain.com", "domain-app-id"},
  15. {"part~partition-app-id", "part", "", "partition-app-id"},
  16. {"part~domain.com:display", "part", "domain.com", "display"},
  17. }
  18. for _, tc := range testCases {
  19. part, dom, dis := parseFullAppID(tc.in)
  20. if part != tc.partition {
  21. t.Errorf("partition of %q: got %q, want %q", tc.in, part, tc.partition)
  22. }
  23. if dom != tc.domain {
  24. t.Errorf("domain of %q: got %q, want %q", tc.in, dom, tc.domain)
  25. }
  26. if dis != tc.displayID {
  27. t.Errorf("displayID of %q: got %q, want %q", tc.in, dis, tc.displayID)
  28. }
  29. }
  30. }