Skip to content

Commit

Permalink
Add a unittest for the resourceScope.
Browse files Browse the repository at this point in the history
  • Loading branch information
boris-smidt-klarrio committed Aug 26, 2024
1 parent 61fde97 commit 7c583fd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion aks.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (self azureClient) SetDiskTags(ctx context.Context, subscription AzureSubsc
if err != nil {
return fmt.Errorf("could not set the tags for: %w", err)
}
log.WithFields(log.Fields{"disk": diskName, "resource-group": resourceGroupName}).Debug("updated disk tags to tags=%v", response.Properties.Tags)
log.WithFields(log.Fields{"disk": diskName, "resource-group": resourceGroupName}).Debugf("updated disk tags to tags=%v", response.Properties.Tags)
return nil
}

Expand Down
28 changes: 28 additions & 0 deletions aks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,31 @@ func Test_sanitizeLabelsForAzure(t *testing.T) {
assert.ErrorIs(t, err, ErrAzureTooManyTags)
})
}

func Test_diskScope(t *testing.T) {
type args struct {
subscription string
resourceGroupName string
diskName string
}
tests := []struct {
name string
args args
want string
}{
{
"it should generate a valid scope for disks",
args{
subscription: "sub",
resourceGroupName: "resource-name",
diskName: "disk-name",
},
"subscriptions/sub/resourceGroups/resource-name/providers/Microsoft.Compute/disks/disk-name",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert.Equalf(t, tt.want, diskScope(tt.args.subscription, tt.args.resourceGroupName, tt.args.diskName), "diskScope(%v, %v, %v)", tt.args.subscription, tt.args.resourceGroupName, tt.args.diskName)
})
}
}

0 comments on commit 7c583fd

Please sign in to comment.