packer/config_test.go
Lucas Bajolet 8d4a9d66ab
config: rm mono-component support from config file (#12998)
The global `PACKER_CONFIG` config file was already deprecated from
Packer core, but now with 1.11.0 since we remove support for
mono-component plugins, we are also removing the capability for that
config file to declare them.

Instead of silently not using those, Packer will now error with a
message pointing to the web docs on how to manage their plugins with the
updated workflows for Packer 1.11 and above.
2024-05-30 14:25:08 +02:00

38 lines
805 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package main
import (
"encoding/json"
"reflect"
"strings"
"testing"
)
func TestDecodeConfig(t *testing.T) {
packerConfig := `
{
"PluginMinPort": 10,
"PluginMaxPort": 25,
"disable_checkpoint": true,
"disable_checkpoint_signature": true,
"provisioners": {
"super-shell": "packer-provisioner-super-shell"
}
}`
var cfg config
err := decodeConfig(strings.NewReader(packerConfig), &cfg)
if err != nil {
t.Fatalf("error encountered decoding configuration: %v", err)
}
var expectedCfg config
json.NewDecoder(strings.NewReader(packerConfig)).Decode(&expectedCfg)
if !reflect.DeepEqual(cfg, expectedCfg) {
t.Errorf("failed to load custom configuration data; expected %v got %v", expectedCfg, cfg)
}
}