Beispiel #1
0
func TestNewConfigCurrencyWrite(t *testing.T) {
	t.Parallel()
	cc := directory.NewConfigCurrency(directory.Backend.CurrencyOptionsBase.String())
	c := directory.MustNewCurrencyISO("EUR")

	w := new(config.MockWrite)

	assert.NoError(t, cc.Write(w, c, scope.WebsiteID, 33))

	assert.Exactly(t, directory.Backend.CurrencyOptionsBase.FQPathInt64(scope.StrWebsites, 33), w.ArgPath)
	assert.Exactly(t, "EUR", w.ArgValue)
}
Beispiel #2
0
func TestNewConfigCurrencyGet(t *testing.T) {
	t.Parallel()
	cc := directory.NewConfigCurrency(directory.Backend.CurrencyOptionsBase.String())

	cr := config.NewMockGetter(
		config.WithMockValues(config.MockPV{
			directory.Backend.CurrencyOptionsBase.FQPathInt64(scope.StrStores, 1): "EUR",
			directory.Backend.CurrencyOptionsBase.FQPathInt64(scope.StrStores, 2): "WIR", // Special Swiss currency
		}),
	)

	cur, err := cc.Get(cr.NewScoped(1, 1, 1))
	assert.NoError(t, err)
	assert.Exactly(t, directory.MustNewCurrencyISO("EUR"), cur)

	cur, err = cc.Get(cr.NewScoped(1, 1, 2))
	assert.EqualError(t, err, "currency: tag is not a recognized currency")
	assert.Exactly(t, directory.Currency{}, cur)
}