From 440cf9835d5c50c472c41f9689ea1e1f6809b4c5 Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Tue, 21 Feb 2017 18:48:03 -0600 Subject: [PATCH] Add enterprise allowance test --- enterprise/enterprise_test.go | 43 +++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/enterprise/enterprise_test.go b/enterprise/enterprise_test.go index 6fc8a64a4..36bc6298f 100644 --- a/enterprise/enterprise_test.go +++ b/enterprise/enterprise_test.go @@ -1,12 +1,12 @@ package enterprise_test import ( + "context" "net/http" "net/http/httptest" + "reflect" "testing" - "golang.org/x/net/context" - "github.com/influxdata/chronograf" "github.com/influxdata/chronograf/enterprise" "github.com/influxdata/chronograf/log" @@ -134,3 +134,42 @@ func Test_Enterprise_ComplainsIfNotOpened(t *testing.T) { t.Error("Expected ErrUnitialized, but was this err:", err) } } + +func TestClient_Allowances(t *testing.T) { + tests := []struct { + name string + + want chronograf.Allowances + }{ + { + name: "All possible enterprise permissions", + want: chronograf.Allowances{ + "NoPermissions", + "ViewAdmin", + "ViewChronograf", + "CreateDatabase", + "CreateUserAndRole", + "AddRemoveNode", + "DropDatabase", + "DropData", + "ReadData", + "WriteData", + "Rebalance", + "ManageShard", + "ManageContinuousQuery", + "ManageQuery", + "ManageSubscription", + "Monitor", + "CopyShard", + "KapacitorAPI", + "KapacitorConfigAPI", + }, + }, + } + for _, tt := range tests { + c := &enterprise.Client{} + if got := c.Allowances(context.Background()); !reflect.DeepEqual(got, tt.want) { + t.Errorf("%q. Client.Allowances() = %v, want %v", tt.name, got, tt.want) + } + } +}