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 5package internal 6 7import ( 8 "testing" 9) 10 11func TestAppIDParsing(t *testing.T) { 12 testCases := []struct { 13 in string 14 partition, domain, displayID string 15 }{ 16 {"simple-app-id", "", "", "simple-app-id"}, 17 {"domain.com:domain-app-id", "", "domain.com", "domain-app-id"}, 18 {"part~partition-app-id", "part", "", "partition-app-id"}, 19 {"part~domain.com:display", "part", "domain.com", "display"}, 20 } 21 22 for _, tc := range testCases { 23 part, dom, dis := parseFullAppID(tc.in) 24 if part != tc.partition { 25 t.Errorf("partition of %q: got %q, want %q", tc.in, part, tc.partition) 26 } 27 if dom != tc.domain { 28 t.Errorf("domain of %q: got %q, want %q", tc.in, dom, tc.domain) 29 } 30 if dis != tc.displayID { 31 t.Errorf("displayID of %q: got %q, want %q", tc.in, dis, tc.displayID) 32 } 33 } 34} 35