github.com/instana/go-sensor@v1.62.2-0.20240520081010-4919868049e1/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 instana "github.com/instana/go-sensor" 10 "github.com/stretchr/testify/assert" 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 }