MM-15276: Migrate Team.Update to sync by default (#10693)

* MM-15276: Migrate Team.Update to sync by default

* MM-15276: Addressing review comments and change Update func signature similar to other interface Update method

* update store mocks for update fn

* addressing review comments
This commit is contained in:
Puneeth Reddy
2019-04-25 06:29:02 -07:00
committed by Jesús Espino
parent b24013d54c
commit ec95793b90
17 changed files with 109 additions and 111 deletions

View File

@@ -303,7 +303,7 @@ func TestModifyCommand(t *testing.T) {
assert.Equal(t, cmd.DisplayName, testVal)
})
t.Run("description nil error", func(t *testing.T) {
t.Run("description nil error", func(t *testing.T) {
testVal := "test description"
args := []string{"command", "modify", command.Id, "--description", testVal}
output, _ := th.RunCommandWithOutput(t, args...)
@@ -312,7 +312,7 @@ func TestModifyCommand(t *testing.T) {
assert.Equal(t, cmd.Description, testVal)
})
t.Run("trigger nil error", func(t *testing.T) {
t.Run("trigger nil error", func(t *testing.T) {
testVal := "testtrigger"
args := []string{"command", "modify", command.Id, "--trigger-word", testVal}
output, _ := th.RunCommandWithOutput(t, args...)
@@ -321,21 +321,21 @@ func TestModifyCommand(t *testing.T) {
assert.Equal(t, cmd.Trigger, testVal)
})
t.Run("trigger with space", func(t *testing.T) {
t.Run("trigger with space", func(t *testing.T) {
testVal := "bad trigger"
args := []string{"command", "modify", command.Id, "--trigger-word", testVal}
output, _ := th.RunCommandWithOutput(t, args...)
assert.Contains(t, string(output), "Error: a trigger word must not contain spaces")
})
t.Run("trigger with leading /", func(t *testing.T) {
t.Run("trigger with leading /", func(t *testing.T) {
testVal := "/bad-trigger"
args := []string{"command", "modify", command.Id, "--trigger-word", testVal}
output, _ := th.RunCommandWithOutput(t, args...)
assert.Contains(t, string(output), "Error: a trigger word cannot begin with a /")
})
t.Run("blank trigger", func(t *testing.T) {
t.Run("blank trigger", func(t *testing.T) {
cmd_unmodified, _ := th.App.GetCommand(command.Id)
args := []string{"command", "modify", command.Id, "--trigger-word", ""}
output, _ := th.RunCommandWithOutput(t, args...)
@@ -347,7 +347,7 @@ func TestModifyCommand(t *testing.T) {
})
//url case
t.Run("url nil error", func(t *testing.T) {
t.Run("url nil error", func(t *testing.T) {
testVal := "http://localhost:8000/modify-command"
args := []string{"command", "modify", command.Id, "--url", testVal}
output, _ := th.RunCommandWithOutput(t, args...)
@@ -356,7 +356,7 @@ func TestModifyCommand(t *testing.T) {
assert.Equal(t, cmd.URL, testVal)
})
t.Run("blank url", func(t *testing.T) {
t.Run("blank url", func(t *testing.T) {
cmd_unmodified, _ := th.App.GetCommand(command.Id)
args := []string{"command", "modify", command.Id, "--url", ""}
output, _ := th.RunCommandWithOutput(t, args...)
@@ -367,7 +367,7 @@ func TestModifyCommand(t *testing.T) {
assert.Equal(t, cmd_unmodified.URL, cmd_modified.URL)
})
t.Run("icon url nil error", func(t *testing.T) {
t.Run("icon url nil error", func(t *testing.T) {
testVal := "http://localhost:8000/testicon.png"
args := []string{"command", "modify", command.Id, "--icon", testVal}
output, _ := th.RunCommandWithOutput(t, args...)
@@ -376,7 +376,7 @@ func TestModifyCommand(t *testing.T) {
assert.Equal(t, cmd.IconURL, testVal)
})
t.Run("creator nil error", func(t *testing.T) {
t.Run("creator nil error", func(t *testing.T) {
testVal := adminUser
args := []string{"command", "modify", command.Id, "--creator", testVal.Username}
output, _ := th.RunCommandWithOutput(t, args...)
@@ -385,21 +385,21 @@ func TestModifyCommand(t *testing.T) {
assert.Equal(t, cmd.CreatorId, testVal.Id)
})
t.Run("creator not found", func(t *testing.T) {
t.Run("creator not found", func(t *testing.T) {
testVal := "fakeuser"
args := []string{"command", "modify", command.Id, "--creator", testVal}
output, _ := th.RunCommandWithOutput(t, args...)
assert.Contains(t, string(output), "unable to find user")
})
t.Run("creator not admin user", func(t *testing.T) {
t.Run("creator not admin user", func(t *testing.T) {
testVal := user.Username
args := []string{"command", "modify", command.Id, "--creator", testVal}
output, _ := th.RunCommandWithOutput(t, args...)
assert.Contains(t, string(output), "the creator must be a user who has permissions to manage slash commands")
})
t.Run("response username nil error", func(t *testing.T) {
t.Run("response username nil error", func(t *testing.T) {
testVal := "response-test"
args := []string{"command", "modify", command.Id, "--response-username", testVal}
output, _ := th.RunCommandWithOutput(t, args...)
@@ -408,7 +408,7 @@ func TestModifyCommand(t *testing.T) {
assert.Equal(t, cmd.Username, testVal)
})
t.Run("post set and unset", func(t *testing.T) {
t.Run("post set and unset", func(t *testing.T) {
args_set := []string{"command", "modify", command.Id, "--post", ""}
args_unset := []string{"command", "modify", command.Id, "", ""}
@@ -425,7 +425,7 @@ func TestModifyCommand(t *testing.T) {
assert.Equal(t, cmd_unset.Method, "G")
})
t.Run("autocomplete set and unset", func(t *testing.T) {
t.Run("autocomplete set and unset", func(t *testing.T) {
args_set := []string{"command", "modify", command.Id, "--autocomplete", ""}
args_unset := []string{"command", "modify", command.Id, "", ""}

View File

@@ -23,7 +23,7 @@ func TestMain(m *testing.M) {
}
var options = testlib.HelperOptions{
EnableStore: true,
EnableStore: true,
EnableResources: true,
}