-
-
Notifications
You must be signed in to change notification settings - Fork 750
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tariff/octopusenergy: fix parsing of tariff setting (#13799)
- Loading branch information
1 parent
72fbbd1
commit d9b3d46
Showing
2 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package tariff | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestOctopusConfigParse(t *testing.T) { | ||
// This test will start failing if you remove the deprecated "tariff" config var. | ||
validTariffConfig := map[string]interface{}{ | ||
"region": "H", | ||
"tariff": "GO-22-03-29", | ||
} | ||
|
||
_, err := NewOctopusFromConfig(validTariffConfig) | ||
require.NoError(t, err) | ||
|
||
validProductCodeConfig := map[string]interface{}{ | ||
"region": "H", | ||
"productcode": "GO-22-03-29", | ||
} | ||
|
||
_, err = NewOctopusFromConfig(validProductCodeConfig) | ||
require.NoError(t, err) | ||
|
||
invalidApiAndProductCodeConfig := map[string]interface{}{ | ||
"region": "H", | ||
"productcode": "GO-22-03-29", | ||
"apikey": "nope", | ||
} | ||
_, err = NewOctopusFromConfig(invalidApiAndProductCodeConfig) | ||
require.Error(t, err) | ||
} |