|
|
|
|
@ -4,6 +4,7 @@
|
|
|
|
|
package packer
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"errors"
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
@ -33,3 +34,24 @@ func TestFlattenConfigKeys_nested(t *testing.T) {
|
|
|
|
|
"Input didn't flatten correctly.",
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestCheckpointTelemetry(t *testing.T) {
|
|
|
|
|
defer func() {
|
|
|
|
|
if r := recover(); r != nil {
|
|
|
|
|
t.Error("a noop CheckpointTelemetry should not to panic but it did\n", r)
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
// A null CheckpointTelemetry obtained in Packer when the CHECKPOINT_DISABLE env var is set results in a NOOP reporter
|
|
|
|
|
// The null reporter can be executable as a configured reporter but does not report any telemetry data.
|
|
|
|
|
var c *CheckpointTelemetry
|
|
|
|
|
c.SetTemplateType(HCL2Template)
|
|
|
|
|
c.SetBundledUsage()
|
|
|
|
|
c.AddSpan("mockprovisioner", "provisioner", nil)
|
|
|
|
|
if err := c.ReportPanic("Bogus Panic"); err != nil {
|
|
|
|
|
t.Errorf("calling ReportPanic on a nil checkpoint reporter should not error")
|
|
|
|
|
}
|
|
|
|
|
if err := c.Finalize("test", 1, errors.New("Bogus Error")); err != nil {
|
|
|
|
|
t.Errorf("calling Finalize on a nil checkpoint reporter should not error")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|