You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by mi...@apache.org on 2017/01/10 03:38:32 UTC

[20/50] incubator-trafficcontrol git commit: add profile test

add profile test


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/72d99eb9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/72d99eb9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/72d99eb9

Branch: refs/heads/master
Commit: 72d99eb9982dc9d204178c1499c90d68e5437b41
Parents: 105e1a4
Author: David Neuman <da...@gmail.com>
Authored: Fri Dec 2 15:36:11 2016 -0700
Committer: Dan Kirkwood <da...@gmail.com>
Committed: Sun Jan 8 21:05:00 2017 -0700

----------------------------------------------------------------------
 .../client/tests/integration/hardware_test.go   |  1 -
 .../client/tests/integration/parameter_test.go  |  3 +-
 .../client/tests/integration/profile_test.go    | 58 ++++++++++++++++++++
 3 files changed, 59 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/72d99eb9/traffic_ops/client/tests/integration/hardware_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/client/tests/integration/hardware_test.go b/traffic_ops/client/tests/integration/hardware_test.go
index 6c7fb47..724c875 100644
--- a/traffic_ops/client/tests/integration/hardware_test.go
+++ b/traffic_ops/client/tests/integration/hardware_test.go
@@ -1,7 +1,6 @@
 package integration
 
 import (
-	// "encoding/json"
 	"encoding/json"
 	"testing"
 

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/72d99eb9/traffic_ops/client/tests/integration/parameter_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/client/tests/integration/parameter_test.go b/traffic_ops/client/tests/integration/parameter_test.go
index 0f57045..8e5f00a 100644
--- a/traffic_ops/client/tests/integration/parameter_test.go
+++ b/traffic_ops/client/tests/integration/parameter_test.go
@@ -1,7 +1,6 @@
 package integration
 
 import (
-	// "encoding/json"
 	"encoding/json"
 	"fmt"
 	"testing"
@@ -32,7 +31,7 @@ func TestParameters(t *testing.T) {
 
 	clientParams, err := to.Parameters(profile.Name)
 	if err != nil {
-		t.Errorf("Could not get Hardware from client.  Error is: %v\n", err)
+		t.Errorf("Could not get parameters from client.  Error is: %v\n", err)
 		t.FailNow()
 	}
 

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/72d99eb9/traffic_ops/client/tests/integration/profile_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/client/tests/integration/profile_test.go b/traffic_ops/client/tests/integration/profile_test.go
new file mode 100644
index 0000000..c4af200
--- /dev/null
+++ b/traffic_ops/client/tests/integration/profile_test.go
@@ -0,0 +1,58 @@
+package integration
+
+import (
+	"encoding/json"
+	"fmt"
+	"testing"
+
+	traffic_ops "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
+)
+
+func TestProfiles(t *testing.T) {
+
+	uri := fmt.Sprintf("/api/1.2/profiles.json")
+	resp, err := Request(*to, "GET", uri, nil)
+	if err != nil {
+		t.Errorf("Could not get %s reponse was: %v\n", uri, err)
+		t.FailNow()
+	}
+
+	defer resp.Body.Close()
+	var apiProfileRes traffic_ops.ProfileResponse
+	if err := json.NewDecoder(resp.Body).Decode(&apiProfileRes); err != nil {
+		t.Errorf("Could not decode profile json.  Error is: %v\n", err)
+		t.FailNow()
+	}
+	apiProfiles := apiProfileRes.Response
+
+	clientProfiles, err := to.Profiles()
+	if err != nil {
+		t.Errorf("Could not get profiles from client.  Error is: %v\n", err)
+		t.FailNow()
+	}
+
+	if len(apiProfiles) != len(clientProfiles) {
+		t.Errorf("Profile Response Length -- expected %v, got %v\n", len(apiProfiles), len(clientProfiles))
+	}
+
+	for _, apiProfile := range apiProfiles {
+		match := false
+		for _, clientProfile := range clientProfiles {
+			if apiProfile.ID == clientProfile.ID {
+				match = true
+				if apiProfile.Description != clientProfile.Description {
+					t.Errorf("Description -- Expected %v, got %v\n", apiProfile.Description, clientProfile.Description)
+				}
+				if apiProfile.LastUpdated != clientProfile.LastUpdated {
+					t.Errorf("Last Updated -- Expected %v, got %v\n", apiProfile.LastUpdated, clientProfile.LastUpdated)
+				}
+				if apiProfile.Name != clientProfile.Name {
+					t.Errorf("Name -- Expected %v, got %v\n", apiProfile.Name, clientProfile.Name)
+				}
+			}
+		}
+		if !match {
+			t.Errorf("Did not get a profile matching %v\n", apiProfile.Name)
+		}
+	}
+}