From 6a13496f4db537cd323d2244bbc5a2c10f4ffbb7 Mon Sep 17 00:00:00 2001 From: Ivan De Marino Date: Wed, 13 Jul 2022 17:13:31 +0100 Subject: [PATCH 1/4] Prefer the use of raw fixtures during testing This is to avoid any side-effect from changes that are outside the immediate domain of this library --- tflog/options_test.go | 11 +++++----- tflog/provider_test.go | 41 +++++++++++++++++++------------------- tflog/subsystem_test.go | 41 +++++++++++++++++++------------------- tfsdklog/options_test.go | 11 +++++----- tfsdklog/sdk_test.go | 41 +++++++++++++++++++------------------- tfsdklog/subsystem_test.go | 41 +++++++++++++++++++------------------- 6 files changed, 90 insertions(+), 96 deletions(-) diff --git a/tflog/options_test.go b/tflog/options_test.go index 060c5af..119326f 100644 --- a/tflog/options_test.go +++ b/tflog/options_test.go @@ -7,7 +7,6 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/go-hclog" "github.com/hashicorp/terraform-plugin-log/internal/loggertest" "github.com/hashicorp/terraform-plugin-log/tflog" ) @@ -34,7 +33,7 @@ func TestWithAdditionalLocationOffset(t *testing.T) { // Caller line (number after colon) should match // tflog.SubsystemTrace() line in test case implementation. "@caller": "/tflog/options_test.go:30", - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": testSubsystemModule, }, @@ -51,7 +50,7 @@ func TestWithAdditionalLocationOffset(t *testing.T) { // tflog.SubsystemTrace() line in testSubsystemTraceHelper // function implementation. "@caller": "/tflog/options_test.go:16", - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": testSubsystemModule, }, @@ -68,7 +67,7 @@ func TestWithAdditionalLocationOffset(t *testing.T) { // testSubsystemTraceHelper() line in test case // implementation. "@caller": "/tflog/options_test.go:63", - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": testSubsystemModule, }, @@ -137,7 +136,7 @@ func TestWithRootFields(t *testing.T) { logMessage: "test message", expectedOutput: []map[string]interface{}{ { - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": testSubsystemModule, "test-subsystem-key": "test-subsystem-value", @@ -154,7 +153,7 @@ func TestWithRootFields(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": testSubsystemModule, "test-root-key": "test-root-value", diff --git a/tflog/provider_test.go b/tflog/provider_test.go index 72af639..66a8f06 100644 --- a/tflog/provider_test.go +++ b/tflog/provider_test.go @@ -6,7 +6,6 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/go-hclog" "github.com/hashicorp/terraform-plugin-log/internal/loggertest" "github.com/hashicorp/terraform-plugin-log/tflog" ) @@ -27,7 +26,7 @@ func TestWith(t *testing.T) { logMessage: "test message", expectedOutput: []map[string]interface{}{ { - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": "provider", "test-with-key": "test-with-value", @@ -39,7 +38,7 @@ func TestWith(t *testing.T) { logMessage: "test message", expectedOutput: []map[string]interface{}{ { - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": "provider", "unfielded-test-with-key": nil, @@ -50,7 +49,7 @@ func TestWith(t *testing.T) { key: "test-with-key", value: "test-with-value", logMessage: "test message", - logadditionalFields: []map[string]interface{}{ + additionalFields: []map[string]interface{}{ { "test-log-key-1": "test-log-value-1", "test-log-key-2": "test-log-value-2", @@ -59,7 +58,7 @@ func TestWith(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": "provider", "test-log-key-1": "test-log-value-1", @@ -83,7 +82,7 @@ func TestWith(t *testing.T) { ctx = loggertest.ProviderRoot(ctx, &outputBuffer) ctx = tflog.With(ctx, testCase.key, testCase.value) - tflog.Trace(ctx, testCase.logMessage, testCase.logadditionalFields...) + tflog.Trace(ctx, testCase.logMessage, testCase.additionalFields...) got, err := loggertest.MultilineJSONDecode(&outputBuffer) @@ -110,7 +109,7 @@ func TestTrace(t *testing.T) { message: "test message", expectedOutput: []map[string]interface{}{ { - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": "provider", }, @@ -127,7 +126,7 @@ func TestTrace(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": "provider", "test-key-1": "test-value-1", @@ -152,7 +151,7 @@ func TestTrace(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": "provider", "test-key-1": "test-value-1-map2", @@ -203,7 +202,7 @@ func TestDebug(t *testing.T) { message: "test message", expectedOutput: []map[string]interface{}{ { - "@level": hclog.Debug.String(), + "@level": "debug", "@message": "test message", "@module": "provider", }, @@ -220,7 +219,7 @@ func TestDebug(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Debug.String(), + "@level": "debug", "@message": "test message", "@module": "provider", "test-key-1": "test-value-1", @@ -245,7 +244,7 @@ func TestDebug(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Debug.String(), + "@level": "debug", "@message": "test message", "@module": "provider", "test-key-1": "test-value-1-map2", @@ -296,7 +295,7 @@ func TestInfo(t *testing.T) { message: "test message", expectedOutput: []map[string]interface{}{ { - "@level": hclog.Info.String(), + "@level": "info", "@message": "test message", "@module": "provider", }, @@ -313,7 +312,7 @@ func TestInfo(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Info.String(), + "@level": "info", "@message": "test message", "@module": "provider", "test-key-1": "test-value-1", @@ -338,7 +337,7 @@ func TestInfo(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Info.String(), + "@level": "info", "@message": "test message", "@module": "provider", "test-key-1": "test-value-1-map2", @@ -389,7 +388,7 @@ func TestWarn(t *testing.T) { message: "test message", expectedOutput: []map[string]interface{}{ { - "@level": hclog.Warn.String(), + "@level": "warn", "@message": "test message", "@module": "provider", }, @@ -406,7 +405,7 @@ func TestWarn(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Warn.String(), + "@level": "warn", "@message": "test message", "@module": "provider", "test-key-1": "test-value-1", @@ -431,7 +430,7 @@ func TestWarn(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Warn.String(), + "@level": "warn", "@message": "test message", "@module": "provider", "test-key-1": "test-value-1-map2", @@ -482,7 +481,7 @@ func TestError(t *testing.T) { message: "test message", expectedOutput: []map[string]interface{}{ { - "@level": hclog.Error.String(), + "@level": "error", "@message": "test message", "@module": "provider", }, @@ -499,7 +498,7 @@ func TestError(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Error.String(), + "@level": "error", "@message": "test message", "@module": "provider", "test-key-1": "test-value-1", @@ -524,7 +523,7 @@ func TestError(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Error.String(), + "@level": "error", "@message": "test message", "@module": "provider", "test-key-1": "test-value-1-map2", diff --git a/tflog/subsystem_test.go b/tflog/subsystem_test.go index e64fd88..2ad38c5 100644 --- a/tflog/subsystem_test.go +++ b/tflog/subsystem_test.go @@ -6,7 +6,6 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/go-hclog" "github.com/hashicorp/terraform-plugin-log/internal/loggertest" "github.com/hashicorp/terraform-plugin-log/tflog" ) @@ -32,7 +31,7 @@ func TestSubsystemWith(t *testing.T) { logMessage: "test message", expectedOutput: []map[string]interface{}{ { - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": testSubsystemModule, "test-with-key": "test-with-value", @@ -44,7 +43,7 @@ func TestSubsystemWith(t *testing.T) { logMessage: "test message", expectedOutput: []map[string]interface{}{ { - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": testSubsystemModule, "unfielded-test-with-key": nil, @@ -55,7 +54,7 @@ func TestSubsystemWith(t *testing.T) { key: "test-with-key", value: "test-with-value", logMessage: "test message", - logadditionalFields: []map[string]interface{}{ + additionalFields: []map[string]interface{}{ { "test-log-key-1": "test-log-value-1", "test-log-key-2": "test-log-value-2", @@ -64,7 +63,7 @@ func TestSubsystemWith(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": testSubsystemModule, "test-log-key-1": "test-log-value-1", @@ -89,7 +88,7 @@ func TestSubsystemWith(t *testing.T) { ctx = tflog.NewSubsystem(ctx, testSubsystem) ctx = tflog.SubsystemWith(ctx, testSubsystem, testCase.key, testCase.value) - tflog.SubsystemTrace(ctx, testSubsystem, testCase.logMessage, testCase.logadditionalFields...) + tflog.SubsystemTrace(ctx, testSubsystem, testCase.logMessage, testCase.additionalFields...) got, err := loggertest.MultilineJSONDecode(&outputBuffer) @@ -116,7 +115,7 @@ func TestSubsystemTrace(t *testing.T) { message: "test message", expectedOutput: []map[string]interface{}{ { - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": testSubsystemModule, }, @@ -133,7 +132,7 @@ func TestSubsystemTrace(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": testSubsystemModule, "test-key-1": "test-value-1", @@ -158,7 +157,7 @@ func TestSubsystemTrace(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": testSubsystemModule, "test-key-1": "test-value-1-map2", @@ -210,7 +209,7 @@ func TestSubsystemDebug(t *testing.T) { message: "test message", expectedOutput: []map[string]interface{}{ { - "@level": hclog.Debug.String(), + "@level": "debug", "@message": "test message", "@module": testSubsystemModule, }, @@ -227,7 +226,7 @@ func TestSubsystemDebug(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Debug.String(), + "@level": "debug", "@message": "test message", "@module": testSubsystemModule, "test-key-1": "test-value-1", @@ -252,7 +251,7 @@ func TestSubsystemDebug(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Debug.String(), + "@level": "debug", "@message": "test message", "@module": testSubsystemModule, "test-key-1": "test-value-1-map2", @@ -304,7 +303,7 @@ func TestSubsystemInfo(t *testing.T) { message: "test message", expectedOutput: []map[string]interface{}{ { - "@level": hclog.Info.String(), + "@level": "info", "@message": "test message", "@module": testSubsystemModule, }, @@ -321,7 +320,7 @@ func TestSubsystemInfo(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Info.String(), + "@level": "info", "@message": "test message", "@module": testSubsystemModule, "test-key-1": "test-value-1", @@ -346,7 +345,7 @@ func TestSubsystemInfo(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Info.String(), + "@level": "info", "@message": "test message", "@module": testSubsystemModule, "test-key-1": "test-value-1-map2", @@ -398,7 +397,7 @@ func TestSubsystemWarn(t *testing.T) { message: "test message", expectedOutput: []map[string]interface{}{ { - "@level": hclog.Warn.String(), + "@level": "warn", "@message": "test message", "@module": testSubsystemModule, }, @@ -415,7 +414,7 @@ func TestSubsystemWarn(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Warn.String(), + "@level": "warn", "@message": "test message", "@module": testSubsystemModule, "test-key-1": "test-value-1", @@ -440,7 +439,7 @@ func TestSubsystemWarn(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Warn.String(), + "@level": "warn", "@message": "test message", "@module": testSubsystemModule, "test-key-1": "test-value-1-map2", @@ -492,7 +491,7 @@ func TestSubsystemError(t *testing.T) { message: "test message", expectedOutput: []map[string]interface{}{ { - "@level": hclog.Error.String(), + "@level": "error", "@message": "test message", "@module": testSubsystemModule, }, @@ -509,7 +508,7 @@ func TestSubsystemError(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Error.String(), + "@level": "error", "@message": "test message", "@module": testSubsystemModule, "test-key-1": "test-value-1", @@ -534,7 +533,7 @@ func TestSubsystemError(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Error.String(), + "@level": "error", "@message": "test message", "@module": testSubsystemModule, "test-key-1": "test-value-1-map2", diff --git a/tfsdklog/options_test.go b/tfsdklog/options_test.go index 7ea4fff..06782c1 100644 --- a/tfsdklog/options_test.go +++ b/tfsdklog/options_test.go @@ -7,7 +7,6 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/go-hclog" "github.com/hashicorp/terraform-plugin-log/internal/loggertest" "github.com/hashicorp/terraform-plugin-log/tfsdklog" ) @@ -34,7 +33,7 @@ func TestWithAdditionalLocationOffset(t *testing.T) { // Caller line (number after colon) should match // tfsdklog.SubsystemTrace() line in test case implementation. "@caller": "/tfsdklog/options_test.go:30", - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": testSubsystemModule, }, @@ -51,7 +50,7 @@ func TestWithAdditionalLocationOffset(t *testing.T) { // tfsdklog.SubsystemTrace() line in testSubsystemTraceHelper // function implementation. "@caller": "/tfsdklog/options_test.go:16", - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": testSubsystemModule, }, @@ -68,7 +67,7 @@ func TestWithAdditionalLocationOffset(t *testing.T) { // testSubsystemTraceHelper() line in test case // implementation. "@caller": "/tfsdklog/options_test.go:63", - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": testSubsystemModule, }, @@ -137,7 +136,7 @@ func TestWithRootFields(t *testing.T) { logMessage: "test message", expectedOutput: []map[string]interface{}{ { - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": testSubsystemModule, "test-subsystem-key": "test-subsystem-value", @@ -154,7 +153,7 @@ func TestWithRootFields(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": testSubsystemModule, "test-root-key": "test-root-value", diff --git a/tfsdklog/sdk_test.go b/tfsdklog/sdk_test.go index 1c1c21c..6d371ea 100644 --- a/tfsdklog/sdk_test.go +++ b/tfsdklog/sdk_test.go @@ -6,7 +6,6 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/go-hclog" "github.com/hashicorp/terraform-plugin-log/internal/loggertest" "github.com/hashicorp/terraform-plugin-log/tfsdklog" ) @@ -27,7 +26,7 @@ func TestWith(t *testing.T) { logMessage: "test message", expectedOutput: []map[string]interface{}{ { - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": "sdk", "test-with-key": "test-with-value", @@ -39,7 +38,7 @@ func TestWith(t *testing.T) { logMessage: "test message", expectedOutput: []map[string]interface{}{ { - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": "sdk", "unfielded-test-with-key": nil, @@ -50,7 +49,7 @@ func TestWith(t *testing.T) { key: "test-with-key", value: "test-with-value", logMessage: "test message", - logadditionalFields: []map[string]interface{}{ + additionalFields: []map[string]interface{}{ { "test-log-key-1": "test-log-value-1", "test-log-key-2": "test-log-value-2", @@ -59,7 +58,7 @@ func TestWith(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": "sdk", "test-log-key-1": "test-log-value-1", @@ -83,7 +82,7 @@ func TestWith(t *testing.T) { ctx = loggertest.SDKRoot(ctx, &outputBuffer) ctx = tfsdklog.With(ctx, testCase.key, testCase.value) - tfsdklog.Trace(ctx, testCase.logMessage, testCase.logadditionalFields...) + tfsdklog.Trace(ctx, testCase.logMessage, testCase.additionalFields...) got, err := loggertest.MultilineJSONDecode(&outputBuffer) @@ -110,7 +109,7 @@ func TestTrace(t *testing.T) { message: "test message", expectedOutput: []map[string]interface{}{ { - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": "sdk", }, @@ -127,7 +126,7 @@ func TestTrace(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": "sdk", "test-key-1": "test-value-1", @@ -152,7 +151,7 @@ func TestTrace(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": "sdk", "test-key-1": "test-value-1-map2", @@ -203,7 +202,7 @@ func TestDebug(t *testing.T) { message: "test message", expectedOutput: []map[string]interface{}{ { - "@level": hclog.Debug.String(), + "@level": "debug", "@message": "test message", "@module": "sdk", }, @@ -220,7 +219,7 @@ func TestDebug(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Debug.String(), + "@level": "debug", "@message": "test message", "@module": "sdk", "test-key-1": "test-value-1", @@ -245,7 +244,7 @@ func TestDebug(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Debug.String(), + "@level": "debug", "@message": "test message", "@module": "sdk", "test-key-1": "test-value-1-map2", @@ -296,7 +295,7 @@ func TestInfo(t *testing.T) { message: "test message", expectedOutput: []map[string]interface{}{ { - "@level": hclog.Info.String(), + "@level": "info", "@message": "test message", "@module": "sdk", }, @@ -313,7 +312,7 @@ func TestInfo(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Info.String(), + "@level": "info", "@message": "test message", "@module": "sdk", "test-key-1": "test-value-1", @@ -338,7 +337,7 @@ func TestInfo(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Info.String(), + "@level": "info", "@message": "test message", "@module": "sdk", "test-key-1": "test-value-1-map2", @@ -389,7 +388,7 @@ func TestWarn(t *testing.T) { message: "test message", expectedOutput: []map[string]interface{}{ { - "@level": hclog.Warn.String(), + "@level": "warn", "@message": "test message", "@module": "sdk", }, @@ -406,7 +405,7 @@ func TestWarn(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Warn.String(), + "@level": "warn", "@message": "test message", "@module": "sdk", "test-key-1": "test-value-1", @@ -431,7 +430,7 @@ func TestWarn(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Warn.String(), + "@level": "warn", "@message": "test message", "@module": "sdk", "test-key-1": "test-value-1-map2", @@ -482,7 +481,7 @@ func TestError(t *testing.T) { message: "test message", expectedOutput: []map[string]interface{}{ { - "@level": hclog.Error.String(), + "@level": "error", "@message": "test message", "@module": "sdk", }, @@ -499,7 +498,7 @@ func TestError(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Error.String(), + "@level": "error", "@message": "test message", "@module": "sdk", "test-key-1": "test-value-1", @@ -524,7 +523,7 @@ func TestError(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Error.String(), + "@level": "error", "@message": "test message", "@module": "sdk", "test-key-1": "test-value-1-map2", diff --git a/tfsdklog/subsystem_test.go b/tfsdklog/subsystem_test.go index 0b374c1..682932f 100644 --- a/tfsdklog/subsystem_test.go +++ b/tfsdklog/subsystem_test.go @@ -6,7 +6,6 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/go-hclog" "github.com/hashicorp/terraform-plugin-log/internal/loggertest" "github.com/hashicorp/terraform-plugin-log/tfsdklog" ) @@ -32,7 +31,7 @@ func TestSubsystemWith(t *testing.T) { logMessage: "test message", expectedOutput: []map[string]interface{}{ { - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": testSubsystemModule, "test-with-key": "test-with-value", @@ -44,7 +43,7 @@ func TestSubsystemWith(t *testing.T) { logMessage: "test message", expectedOutput: []map[string]interface{}{ { - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": testSubsystemModule, "unfielded-test-with-key": nil, @@ -55,7 +54,7 @@ func TestSubsystemWith(t *testing.T) { key: "test-with-key", value: "test-with-value", logMessage: "test message", - logadditionalFields: []map[string]interface{}{ + additionalFields: []map[string]interface{}{ { "test-log-key-1": "test-log-value-1", "test-log-key-2": "test-log-value-2", @@ -64,7 +63,7 @@ func TestSubsystemWith(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": testSubsystemModule, "test-log-key-1": "test-log-value-1", @@ -89,7 +88,7 @@ func TestSubsystemWith(t *testing.T) { ctx = tfsdklog.NewSubsystem(ctx, testSubsystem) ctx = tfsdklog.SubsystemWith(ctx, testSubsystem, testCase.key, testCase.value) - tfsdklog.SubsystemTrace(ctx, testSubsystem, testCase.logMessage, testCase.logadditionalFields...) + tfsdklog.SubsystemTrace(ctx, testSubsystem, testCase.logMessage, testCase.additionalFields...) got, err := loggertest.MultilineJSONDecode(&outputBuffer) @@ -116,7 +115,7 @@ func TestSubsystemTrace(t *testing.T) { message: "test message", expectedOutput: []map[string]interface{}{ { - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": testSubsystemModule, }, @@ -133,7 +132,7 @@ func TestSubsystemTrace(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": testSubsystemModule, "test-key-1": "test-value-1", @@ -158,7 +157,7 @@ func TestSubsystemTrace(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Trace.String(), + "@level": "trace", "@message": "test message", "@module": testSubsystemModule, "test-key-1": "test-value-1-map2", @@ -210,7 +209,7 @@ func TestSubsystemDebug(t *testing.T) { message: "test message", expectedOutput: []map[string]interface{}{ { - "@level": hclog.Debug.String(), + "@level": "debug", "@message": "test message", "@module": testSubsystemModule, }, @@ -227,7 +226,7 @@ func TestSubsystemDebug(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Debug.String(), + "@level": "debug", "@message": "test message", "@module": testSubsystemModule, "test-key-1": "test-value-1", @@ -252,7 +251,7 @@ func TestSubsystemDebug(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Debug.String(), + "@level": "debug", "@message": "test message", "@module": testSubsystemModule, "test-key-1": "test-value-1-map2", @@ -304,7 +303,7 @@ func TestSubsystemInfo(t *testing.T) { message: "test message", expectedOutput: []map[string]interface{}{ { - "@level": hclog.Info.String(), + "@level": "info", "@message": "test message", "@module": testSubsystemModule, }, @@ -321,7 +320,7 @@ func TestSubsystemInfo(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Info.String(), + "@level": "info", "@message": "test message", "@module": testSubsystemModule, "test-key-1": "test-value-1", @@ -346,7 +345,7 @@ func TestSubsystemInfo(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Info.String(), + "@level": "info", "@message": "test message", "@module": testSubsystemModule, "test-key-1": "test-value-1-map2", @@ -398,7 +397,7 @@ func TestSubsystemWarn(t *testing.T) { message: "test message", expectedOutput: []map[string]interface{}{ { - "@level": hclog.Warn.String(), + "@level": "warn", "@message": "test message", "@module": testSubsystemModule, }, @@ -415,7 +414,7 @@ func TestSubsystemWarn(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Warn.String(), + "@level": "warn", "@message": "test message", "@module": testSubsystemModule, "test-key-1": "test-value-1", @@ -440,7 +439,7 @@ func TestSubsystemWarn(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Warn.String(), + "@level": "warn", "@message": "test message", "@module": testSubsystemModule, "test-key-1": "test-value-1-map2", @@ -492,7 +491,7 @@ func TestSubsystemError(t *testing.T) { message: "test message", expectedOutput: []map[string]interface{}{ { - "@level": hclog.Error.String(), + "@level": "error", "@message": "test message", "@module": testSubsystemModule, }, @@ -509,7 +508,7 @@ func TestSubsystemError(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Error.String(), + "@level": "error", "@message": "test message", "@module": testSubsystemModule, "test-key-1": "test-value-1", @@ -534,7 +533,7 @@ func TestSubsystemError(t *testing.T) { }, expectedOutput: []map[string]interface{}{ { - "@level": hclog.Error.String(), + "@level": "error", "@message": "test message", "@module": testSubsystemModule, "test-key-1": "test-value-1-map2", From c61ac00fc7d0cc23db9aa2124a35bec49f26adca Mon Sep 17 00:00:00 2001 From: Ivan De Marino Date: Wed, 13 Jul 2022 17:13:40 +0100 Subject: [PATCH 2/4] Fix typos --- tflog/provider_test.go | 10 +++++----- tflog/subsystem_test.go | 10 +++++----- tfsdklog/sdk_test.go | 10 +++++----- tfsdklog/subsystem_test.go | 10 +++++----- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/tflog/provider_test.go b/tflog/provider_test.go index 66a8f06..1583045 100644 --- a/tflog/provider_test.go +++ b/tflog/provider_test.go @@ -14,11 +14,11 @@ func TestWith(t *testing.T) { t.Parallel() testCases := map[string]struct { - key string - value interface{} - logMessage string - logadditionalFields []map[string]interface{} - expectedOutput []map[string]interface{} + key string + value interface{} + logMessage string + additionalFields []map[string]interface{} + expectedOutput []map[string]interface{} }{ "no-log-fields": { key: "test-with-key", diff --git a/tflog/subsystem_test.go b/tflog/subsystem_test.go index 2ad38c5..1ec712c 100644 --- a/tflog/subsystem_test.go +++ b/tflog/subsystem_test.go @@ -19,11 +19,11 @@ func TestSubsystemWith(t *testing.T) { t.Parallel() testCases := map[string]struct { - key string - value interface{} - logMessage string - logadditionalFields []map[string]interface{} - expectedOutput []map[string]interface{} + key string + value interface{} + logMessage string + additionalFields []map[string]interface{} + expectedOutput []map[string]interface{} }{ "no-log-fields": { key: "test-with-key", diff --git a/tfsdklog/sdk_test.go b/tfsdklog/sdk_test.go index 6d371ea..2d1d6fd 100644 --- a/tfsdklog/sdk_test.go +++ b/tfsdklog/sdk_test.go @@ -14,11 +14,11 @@ func TestWith(t *testing.T) { t.Parallel() testCases := map[string]struct { - key string - value interface{} - logMessage string - logadditionalFields []map[string]interface{} - expectedOutput []map[string]interface{} + key string + value interface{} + logMessage string + additionalFields []map[string]interface{} + expectedOutput []map[string]interface{} }{ "no-log-fields": { key: "test-with-key", diff --git a/tfsdklog/subsystem_test.go b/tfsdklog/subsystem_test.go index 682932f..86cf3e9 100644 --- a/tfsdklog/subsystem_test.go +++ b/tfsdklog/subsystem_test.go @@ -19,11 +19,11 @@ func TestSubsystemWith(t *testing.T) { t.Parallel() testCases := map[string]struct { - key string - value interface{} - logMessage string - logadditionalFields []map[string]interface{} - expectedOutput []map[string]interface{} + key string + value interface{} + logMessage string + additionalFields []map[string]interface{} + expectedOutput []map[string]interface{} }{ "no-log-fields": { key: "test-with-key", From 472ffdc9769e7168caecb70c0927300d32223fb0 Mon Sep 17 00:00:00 2001 From: Ivan De Marino Date: Wed, 13 Jul 2022 17:13:49 +0100 Subject: [PATCH 3/4] Ignore JetBrains IDEs project files --- .gitignore | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1fa9f4e..637ea69 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ node_modules -website-preview \ No newline at end of file +website-preview + +# Jetbrains IDEs +.idea/ +*.iws From c697ada036ec8b22ce736e38ea57d5fb3a8200a2 Mon Sep 17 00:00:00 2001 From: Ivan De Marino Date: Wed, 13 Jul 2022 17:21:38 +0100 Subject: [PATCH 4/4] Fixed fixtures --- tflog/options_test.go | 6 +++--- tfsdklog/options_test.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tflog/options_test.go b/tflog/options_test.go index 119326f..aeff92b 100644 --- a/tflog/options_test.go +++ b/tflog/options_test.go @@ -32,7 +32,7 @@ func TestWithAdditionalLocationOffset(t *testing.T) { { // Caller line (number after colon) should match // tflog.SubsystemTrace() line in test case implementation. - "@caller": "/tflog/options_test.go:30", + "@caller": "/tflog/options_test.go:29", "@level": "trace", "@message": "test message", "@module": testSubsystemModule, @@ -49,7 +49,7 @@ func TestWithAdditionalLocationOffset(t *testing.T) { // Caller line (number after colon) should match // tflog.SubsystemTrace() line in testSubsystemTraceHelper // function implementation. - "@caller": "/tflog/options_test.go:16", + "@caller": "/tflog/options_test.go:15", "@level": "trace", "@message": "test message", "@module": testSubsystemModule, @@ -66,7 +66,7 @@ func TestWithAdditionalLocationOffset(t *testing.T) { // Caller line (number after colon) should match // testSubsystemTraceHelper() line in test case // implementation. - "@caller": "/tflog/options_test.go:63", + "@caller": "/tflog/options_test.go:62", "@level": "trace", "@message": "test message", "@module": testSubsystemModule, diff --git a/tfsdklog/options_test.go b/tfsdklog/options_test.go index 06782c1..df9902c 100644 --- a/tfsdklog/options_test.go +++ b/tfsdklog/options_test.go @@ -32,7 +32,7 @@ func TestWithAdditionalLocationOffset(t *testing.T) { { // Caller line (number after colon) should match // tfsdklog.SubsystemTrace() line in test case implementation. - "@caller": "/tfsdklog/options_test.go:30", + "@caller": "/tfsdklog/options_test.go:29", "@level": "trace", "@message": "test message", "@module": testSubsystemModule, @@ -49,7 +49,7 @@ func TestWithAdditionalLocationOffset(t *testing.T) { // Caller line (number after colon) should match // tfsdklog.SubsystemTrace() line in testSubsystemTraceHelper // function implementation. - "@caller": "/tfsdklog/options_test.go:16", + "@caller": "/tfsdklog/options_test.go:15", "@level": "trace", "@message": "test message", "@module": testSubsystemModule, @@ -66,7 +66,7 @@ func TestWithAdditionalLocationOffset(t *testing.T) { // Caller line (number after colon) should match // testSubsystemTraceHelper() line in test case // implementation. - "@caller": "/tfsdklog/options_test.go:63", + "@caller": "/tfsdklog/options_test.go:62", "@level": "trace", "@message": "test message", "@module": testSubsystemModule,