From 7b4b72eba42e03b9200f48e38aecfe0186a7d211 Mon Sep 17 00:00:00 2001 From: Rowan Seymour Date: Wed, 2 May 2018 10:19:10 -0500 Subject: [PATCH] Remove Resolve functionality which now lives in goflow's ContactURN --- urns/urns.go | 16 ---------------- urns/urns_test.go | 36 ------------------------------------ 2 files changed, 52 deletions(-) diff --git a/urns/urns.go b/urns/urns.go index 2bf824d..c6954a3 100644 --- a/urns/urns.go +++ b/urns/urns.go @@ -311,22 +311,6 @@ func (u URN) FacebookRef() string { return "" } -// Resolve is called when a URN is part of an excellent expression -func (u URN) Resolve(key string) interface{} { - switch key { - case "display": - return u.Display() - case "path": - return u.Path() - case "scheme": - return u.Scheme() - } - return fmt.Errorf("no field '%s' on URN", key) -} - -// Default is called when a URN is part of an excellent expression -func (u URN) Default() interface{} { return u } - // String returns the string representation of this URN func (u URN) String() string { return string(u) } diff --git a/urns/urns_test.go b/urns/urns_test.go index b5d7285..618b5b9 100644 --- a/urns/urns_test.go +++ b/urns/urns_test.go @@ -1,7 +1,6 @@ package urns import ( - "fmt" "net/url" "strings" "testing" @@ -82,41 +81,6 @@ func TestFormat(t *testing.T) { } } -func TestResolve(t *testing.T) { - testCases := []struct { - urn URN - key string - hasValue bool - value string - }{ - {"facebook:ref:12345", "scheme", true, "facebook"}, - {"facebook:ref:12345", "display", true, ""}, - {"facebook:ref:12345", "path", true, "ref:12345"}, - {"twitter:85114#foobar", "display", true, "foobar"}, - {"twitter:85114#foobar", "notkey", false, ""}, - } - for _, tc := range testCases { - val := tc.urn.Resolve(tc.key) - err, isErr := val.(error) - - if tc.hasValue && isErr { - t.Errorf("Got unexpected error resolving %s for %s: %s", tc.key, tc.urn, err) - } - - if !tc.hasValue && !isErr { - t.Errorf("Did not get expected error resolving %s for %s: %s", tc.key, tc.urn, err) - } - - if tc.hasValue && tc.value != val { - t.Errorf("Did not get expected value resolving %s for %s. Got %s expected %s", tc.key, tc.urn, val, tc.value) - } - - if fmt.Sprintf("%s", tc.urn.Default()) != tc.urn.String() { - t.Errorf("Default value was not string value for %s", tc.urn) - } - } -} - func TestFromParts(t *testing.T) { testCases := []struct { scheme string