Skip to content

Commit

Permalink
code review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
roperzh committed Oct 9, 2023
1 parent 50115e0 commit e344e54
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
1 change: 0 additions & 1 deletion ee/server/service/scripts.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,6 @@ func (svc *Service) BatchSetScripts(ctx context.Context, maybeTmID *uint, maybeT
}

if byName[script.Name] {
// TODO: check error message
return ctxerr.Wrap(ctx,
fleet.NewInvalidArgumentError(fmt.Sprintf("scripts[%d]", i), fmt.Sprintf("Couldn’t edit scripts. More than one script has the same file name: %q", script.Name)),
"duplicate script by name")
Expand Down
2 changes: 1 addition & 1 deletion server/datastore/mysql/scripts.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ ON DUPLICATE KEY UPDATE
// existing ones if there's a match and no change
incomingNames := make([]string, len(scripts))
// at the same time, index the incoming scripts keyed by name for ease
// or processing
// of processing
incomingScripts := make(map[string]*fleet.Script, len(scripts))
for i, p := range scripts {
incomingNames[i] = p.Name
Expand Down
14 changes: 7 additions & 7 deletions server/datastore/mysql/scripts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,14 +534,14 @@ func testBatchSetScripts(t *testing.T, ds *Datastore) {

// compare only the fields we care about
m := make(map[string]uint)
for _, gotp := range got {
m[gotp.Name] = gotp.ID
if gotp.TeamID != nil && *gotp.TeamID == 0 {
gotp.TeamID = nil
for _, gotScript := range got {
m[gotScript.Name] = gotScript.ID
if gotScript.TeamID != nil && *gotScript.TeamID == 0 {
gotScript.TeamID = nil
}
gotp.ID = 0
gotp.CreatedAt = time.Time{}
gotp.UpdatedAt = time.Time{}
gotScript.ID = 0
gotScript.CreatedAt = time.Time{}
gotScript.UpdatedAt = time.Time{}
}
// order is not guaranteed
require.ElementsMatch(t, want, got)
Expand Down
2 changes: 1 addition & 1 deletion server/service/integration_enterprise_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4922,7 +4922,7 @@ func (s *integrationEnterpriseTestSuite) TestBatchApplyScriptsEndpoints() {
teamActivity = fmt.Sprintf(`{"team_id": %d, "team_name": %q}`, team.ID, team.Name)
}

// create an check activities
// create and check activities
s.Do("POST", "/api/v1/fleet/scripts/batch", batchSetScriptsRequest{Scripts: scripts}, http.StatusNoContent, "team_id", teamIDStr)
s.lastActivityMatches(
fleet.ActivityTypeEditedScript{}.ActivityName(),
Expand Down

0 comments on commit e344e54

Please sign in to comment.