From 9fe20bfab8a19eba1f42ac86f9e34e73cf1d8bab Mon Sep 17 00:00:00 2001 From: JJ Jordan Date: Fri, 16 Mar 2018 14:50:38 -0700 Subject: [PATCH] Add minor tests, comments --- appinsights/telemetry.go | 2 ++ appinsights/telemetry_test.go | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/appinsights/telemetry.go b/appinsights/telemetry.go index 3498fa0..40e76da 100644 --- a/appinsights/telemetry.go +++ b/appinsights/telemetry.go @@ -51,11 +51,13 @@ type baseTelemetry struct { Tags contracts.ContextTags } +// Mixin type for telemetry that includes Measurements. type baseTelemetryMeasurements struct { // Custom measurements Measurements map[string]float64 } +// Mixin type for telemetry that omits Measurements. type baseTelemetryNoMeasurements struct { } diff --git a/appinsights/telemetry_test.go b/appinsights/telemetry_test.go index 9bb64a5..ed26bba 100644 --- a/appinsights/telemetry_test.go +++ b/appinsights/telemetry_test.go @@ -59,6 +59,11 @@ func TestTraceTelemetry(t *testing.T) { checkDataContract(t, "Message", d2.Message, "~my-2nd-message~") checkDataContract(t, "SeverityLevel", d2.SeverityLevel, Critical) + + var telemInterface Telemetry + if telemInterface = telem; telemInterface.GetMeasurements() != nil { + t.Errorf("Trace.(Telemetry).GetMeasurements should return nil") + } } func TestEventTelemetry(t *testing.T) { @@ -118,6 +123,11 @@ func TestMetricTelemetry(t *testing.T) { checkDataContract(t, "DataPoint.Value", dp2.Value, 5678.0) checkDataContract(t, "DataPoint.Kind", dp2.Kind, Measurement) checkDataContract(t, "DataPoint.Count", dp2.Count, 1) + + var telemInterface Telemetry + if telemInterface = telem; telemInterface.GetMeasurements() != nil { + t.Errorf("Metric.(Telemetry).GetMeasurements should return nil") + } } type statsTest struct {