github.com/mier85/go-sensor@v1.30.1-0.20220920111756-9bf41b3bc7e0/eum_test.go (about)

     1  // (c) Copyright IBM Corp. 2021
     2  // (c) Copyright Instana Inc. 2018
     3  
     4  package instana_test
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/instana/testify/assert"
    10  	instana "github.com/mier85/go-sensor"
    11  )
    12  
    13  const eumExpectedResult string = `<script>
    14  (function(c,e,f,k,g,h,b,a,d){c[g]||(c[g]=h,b=c[h]=function(){b.q.push(arguments)},b.q=[],b.l=1*new Date,a=e.createElement(f),a.async=1,a.src=k,a.setAttribute("crossorigin","anonymous"),d=e.getElementsByTagName(f)[0],d.parentNode.insertBefore(a,d))})(window,document,"script","//eum.instana.io/eum.min.js","InstanaEumObject","ineum");ineum('reportingUrl','https://eum-saas.instana.io');ineum('key','myApiKey');ineum('traceId','myTraceId');ineum('meta','key1','value1');ineum('meta','key2','value2');
    15  </script>
    16  `
    17  
    18  func TestEum(t *testing.T) {
    19  	assert.Equal(t, eumExpectedResult, instana.EumSnippet("myApiKey", "myTraceId", map[string]string{
    20  		"key1": "value1",
    21  		"key2": "value2",
    22  	}))
    23  }