hunk.code_window: 	if channel := <-app.Srv.Store.Channel().GetByName(c.TeamId, channelName, true); channel.Err != nil {
   		if channel.Err.Id == "store.sql_channel.get_by_name.missing.app_error" {
   			if directChannel, err := app.CreateDirectChannel(c.Session.UserId, userProfile.Id); err != nil {
   				c.Err = err
   				return &model.CommandResponse{Text: c.T("api.command_msg.dm_fail.app_error"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
   			} else {
   				targetChannelId = directChannel.Id
   			}
  
hunk.labels: keep keep keep replace keep keep keep keep
hunk.after_edit: 				l4g.Error(err.Error())
  
hunk.file_path: api/command_msg.go
hunk.type: replace
file: // Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
  // See License.txt for license information.
  
  package app
  
  import (
  	"testing"
  
  	"github.com/mattermost/platform/model"
  )
  
  func TestCheckIfRolesGrantPermission(t *testing.T) {
  	Setup()
  
  	cases := []struct {
  		roles        []string
  		permissionId string
  		shouldGrant  bool
  	}{
  		{[]string{model.ROLE_SYSTEM_ADMIN.Id}, model.ROLE_SYSTEM_ADMIN.Permissions[0], true},
  		{[]string{model.ROLE_SYSTEM_ADMIN.Id}, "non-existant-permission", false},
  		{[]string{model.ROLE_CHANNEL_USER.Id}, model.ROLE_CHANNEL_USER.Permissions[0], true},
  		{[]string{model.ROLE_CHANNEL_USER.Id}, model.PERMISSION_MANAGE_SYSTEM.Id, false},
  		{[]string{model.ROLE_SYSTEM_ADMIN.Id, model.ROLE_CHANNEL_USER.Id}, model.PERMISSION_MANAGE_SYSTEM.Id, true},
  		{[]string{model.ROLE_CHANNEL_USER.Id, model.ROLE_SYSTEM_ADMIN.Id}, model.PERMISSION_MANAGE_SYSTEM.Id, true},
  		{[]string{model.ROLE_TEAM_USER.Id, model.ROLE_TEAM_ADMIN.Id}, model.PERMISSION_MANAGE_SLASH_COMMANDS.Id, true},
  		{[]string{model.ROLE_TEAM_ADMIN.Id, model.ROLE_TEAM_USER.Id}, model.PERMISSION_MANAGE_SLASH_COMMANDS.Id, true},
  	}
  
  	for testnum, testcase := range cases {
  		if CheckIfRolesGrantPermission(testcase.roles, testcase.permissionId) != testcase.shouldGrant {
  			t.Fatal("Failed test case ", testnum)
  		}
  	}
  
  }
  