@@ -30,6 +30,7 @@ func Test_CollectDataAPI(t *testing.T) {
3030 options : controller.GoFeatureFlagApiOptions {
3131 Endpoint : "http://localhost:1031" ,
3232 APIKey : "" ,
33+ CustomHeaders : map [string ]string {"User-Agent" : "goff-sdk-tests" },
3334 ExporterMetadata : map [string ]any {"openfeature" : true , "provider" : "go" },
3435 },
3536 events : []model.FeatureEvent {
@@ -67,6 +68,7 @@ func Test_CollectDataAPI(t *testing.T) {
6768 wantHeaders : func () http.Header {
6869 headers := http.Header {}
6970 headers .Set (controller .ContentTypeHeader , controller .ApplicationJson )
71+ headers .Set ("User-Agent" , "goff-sdk-tests" )
7072 return headers
7173 }(),
7274 wantReqBody : "{\" events\" :[{\" kind\" :\" feature\" ,\" contextKind\" :\" user\" ,\" userKey\" :\" ABCD\" ,\" creationDate\" :1722266324,\" key\" :\" random-key\" ,\" variation\" :\" variationA\" ,\" value\" :\" YO\" ,\" default\" :false,\" version\" :\" \" ,\" source\" :\" SERVER\" },{\" kind\" :\" feature\" ,\" contextKind\" :\" user\" ,\" userKey\" :\" EFGH\" ,\" creationDate\" :1722266324,\" key\" :\" random-key\" ,\" variation\" :\" variationA\" ,\" value\" :\" YO\" ,\" default\" :false,\" version\" :\" \" ,\" source\" :\" SERVER\" }],\" meta\" :{\" openfeature\" :true,\" provider\" :\" go\" }}" ,
@@ -77,6 +79,7 @@ func Test_CollectDataAPI(t *testing.T) {
7779 options : controller.GoFeatureFlagApiOptions {
7880 Endpoint : "http://localhost:1031" ,
7981 APIKey : "my-key" ,
82+ CustomHeaders : map [string ]string {"User-Agent" : "goff-sdk-tests" },
8083 ExporterMetadata : map [string ]any {"openfeature" : true , "provider" : "go" },
8184 },
8285 events : []model.FeatureEvent {
@@ -115,6 +118,7 @@ func Test_CollectDataAPI(t *testing.T) {
115118 headers := http.Header {}
116119 headers .Set (controller .ContentTypeHeader , controller .ApplicationJson )
117120 headers .Set (controller .AuthorizationHeader , controller .BearerPrefix + "my-key" )
121+ headers .Set ("User-Agent" , "goff-sdk-tests" )
118122 return headers
119123 }(),
120124 wantReqBody : "{\" events\" :[{\" kind\" :\" feature\" ,\" contextKind\" :\" user\" ,\" userKey\" :\" ABCD\" ,\" creationDate\" :1722266324,\" key\" :\" random-key\" ,\" variation\" :\" variationA\" ,\" value\" :\" YO\" ,\" default\" :false,\" version\" :\" \" ,\" source\" :\" SERVER\" },{\" kind\" :\" feature\" ,\" contextKind\" :\" user\" ,\" userKey\" :\" EFGH\" ,\" creationDate\" :1722266324,\" key\" :\" random-key\" ,\" variation\" :\" variationA\" ,\" value\" :\" YO\" ,\" default\" :false,\" version\" :\" \" ,\" source\" :\" SERVER\" }],\" meta\" :{\" openfeature\" :true,\" provider\" :\" go\" }}" ,
@@ -181,13 +185,15 @@ func Test_ConfigurationHasChanged(t *testing.T) {
181185 }}
182186 client := & http.Client {Transport : & mrt }
183187 options := controller.GoFeatureFlagApiOptions {
184- Endpoint : "http://localhost:1031" ,
185- HTTPClient : client ,
188+ Endpoint : "http://localhost:1031" ,
189+ HTTPClient : client ,
190+ CustomHeaders : map [string ]string {"User-Agent" : "goff-sdk-tests" },
186191 }
187192 g := controller .NewGoFeatureFlagAPI (options )
188193 status , err := g .ConfigurationHasChanged ()
189194 require .NoError (t , err )
190195 assert .Equal (t , controller .FlagConfigurationInitialized , status )
196+ assert .Equal (t , "goff-sdk-tests" , mrt .GetLastRequest ().Header .Get ("User-Agent" ))
191197 })
192198
193199 t .Run ("Change in the configuration" , func (t * testing.T ) {
0 commit comments