Add enterprise allowance test

pull/101/head
Chris Goller 2017-02-21 18:48:03 -06:00
parent 0b95dfecbb
commit 440cf9835d
1 changed files with 41 additions and 2 deletions

View File

@ -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)
}
}
}