@@ -285,16 +285,6 @@ func TestGetOffers(t *testing.T) {
285285 apiKey : "test-api-key" ,
286286 }
287287
288- offers , err := service .GetOffers ()
289- if err != nil {
290- t .Fatalf ("GetOffers returned error: %v" , err )
291- }
292-
293- expectedOfferCount := 1
294- if len (offers ) != expectedOfferCount {
295- t .Errorf ("Expected %d offers, got %d" , expectedOfferCount , len (offers ))
296- }
297-
298288 eurPrice := lavatopvalueobjects .NewPrice (48 , lavatopvalueobjects .EUR , lavatopvalueobjects .ONE_TIME )
299289 rubPrice := lavatopvalueobjects .NewPrice (5000 , lavatopvalueobjects .RUB , lavatopvalueobjects .ONE_TIME )
300290 usdPrice := lavatopvalueobjects .NewPrice (49 , lavatopvalueobjects .USD , lavatopvalueobjects .ONE_TIME )
@@ -306,24 +296,36 @@ func TestGetOffers(t *testing.T) {
306296 prices ,
307297 )
308298
309- if offers [0 ].ExtId () != expectedOffer .ExtId () {
310- t .Errorf ("Expected offer ID %s, got %s" , expectedOffer .ExtId (), offers [0 ].ExtId ())
299+ offers , err := service .GetOffers ()
300+ if err != nil {
301+ t .Fatalf ("GetOffers returned error: %v" , err )
302+ }
303+
304+ expectedOfferCount := 1
305+ if len (offers ) != expectedOfferCount {
306+ t .Errorf ("Expected %d offers, got %d" , expectedOfferCount , len (offers ))
307+ }
308+
309+ actualOffer := offers [0 ]
310+
311+ if actualOffer .ExtId () != expectedOffer .ExtId () {
312+ t .Errorf ("Expected offer ID %s, got %s" , expectedOffer .ExtId (), actualOffer .ExtId ())
311313 }
312314
313- if offers [ 0 ] .Name () != expectedOffer .Name () {
314- t .Errorf ("Expected offer name %s, got %s" , expectedOffer .Name (), offers [ 0 ] .Name ())
315+ if actualOffer .Name () != expectedOffer .Name () {
316+ t .Errorf ("Expected offer name %s, got %s" , expectedOffer .Name (), actualOffer .Name ())
315317 }
316318
317- if offers [ 0 ] .Prices ()[0 ].Cents () != expectedOffer .Prices ()[0 ].Cents () {
318- t .Errorf ("Expected price %d, got %d" , expectedOffer .Prices ()[0 ].Cents (), offers [ 0 ] .Prices ()[0 ].Cents ())
319+ if actualOffer .Prices ()[0 ].Cents () != expectedOffer .Prices ()[0 ].Cents () {
320+ t .Errorf ("Expected price %d, got %d" , expectedOffer .Prices ()[0 ].Cents (), actualOffer .Prices ()[0 ].Cents ())
319321 }
320322
321- if offers [ 0 ] .Prices ()[0 ].Currency () != expectedOffer .Prices ()[0 ].Currency () {
322- t .Errorf ("Expected currency %s, got %s" , expectedOffer .Prices ()[0 ].Currency (), offers [ 0 ] .Prices ()[0 ].Currency ())
323+ if actualOffer .Prices ()[0 ].Currency () != expectedOffer .Prices ()[0 ].Currency () {
324+ t .Errorf ("Expected currency %s, got %s" , expectedOffer .Prices ()[0 ].Currency (), actualOffer .Prices ()[0 ].Currency ())
323325 }
324326
325- if offers [ 0 ] .Prices ()[0 ].Periodicity () != expectedOffer .Prices ()[0 ].Periodicity () {
326- t .Errorf ("Expected periodicity %s, got %s" , expectedOffer .Prices ()[0 ].Periodicity (), offers [ 0 ] .Prices ()[0 ].Periodicity ())
327+ if actualOffer .Prices ()[0 ].Periodicity () != expectedOffer .Prices ()[0 ].Periodicity () {
328+ t .Errorf ("Expected periodicity %s, got %s" , expectedOffer .Prices ()[0 ].Periodicity (), actualOffer .Prices ()[0 ].Periodicity ())
327329 }
328330
329331 expectedPrices := make (map [string ]lavatopvalueobjects.Price )
0 commit comments