Files
Packer-Cn/fix/fixer_galaxy_command_test.go
fb8fa2b0fe [COMPLIANCE] Add/Update Copyright Headers (#13699)
* [COMPLIANCE] Add/Update Copyright Headers

* make generate update

* make generate

---------

Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
Co-authored-by: sanya <[email protected]>
Co-authored-by: Sanya <[email protected]>
2026-09-15 17:10:54 +05:30

83 lines
1.7 KiB
Go

// Copyright IBM Corp. 2024, 2026
// SPDX-License-Identifier: BUSL-1.1
package fix
import (
"reflect"
"testing"
)
func TestFixerGalaxyCommand_Impl(t *testing.T) {
var _ Fixer = new(FixerGalaxyCommand)
}
func TestFixerGalaxyCommand_Fix(t *testing.T) {
cases := []struct {
Input map[string]interface{}
Expected map[string]interface{}
}{
// set galaxy_command
{
Input: map[string]interface{}{
"type": "ansible-local",
"galaxy_command": "/usr/local/bin/ansible-galaxy",
},
Expected: map[string]interface{}{
"type": "ansible-local",
"galaxy_command": "/usr/local/bin/ansible-galaxy",
},
},
// set galaxycommand (old key)
{
Input: map[string]interface{}{
"type": "ansible-local",
"galaxycommand": "/usr/bin/ansible-galaxy",
},
Expected: map[string]interface{}{
"type": "ansible-local",
"galaxy_command": "/usr/bin/ansible-galaxy",
},
},
// set galaxy_command and galaxycommand
// galaxy_command takes precedence
{
Input: map[string]interface{}{
"type": "ansible-local",
"galaxy_command": "ansible_galaxy_command",
"galaxycommand": "ansible_galaxycommand",
},
Expected: map[string]interface{}{
"type": "ansible-local",
"galaxy_command": "ansible_galaxy_command",
},
},
}
for _, tc := range cases {
var f FixerGalaxyCommand
input := map[string]interface{}{
"provisioners": []interface{}{tc.Input},
}
expected := map[string]interface{}{
"provisioners": []interface{}{tc.Expected},
}
output, err := f.Fix(input)
if err != nil {
t.Fatalf("err: %s", err)
}
if !reflect.DeepEqual(output, expected) {
t.Fatalf("unexpected: %#v\nexpected: %#v\n", output, expected)
}
}
}