Files
Alessandro ScandoneandGitHub 5dfc34cd3c feat: feature flag syntax (#120)
* feat: feature flag syntax

* feat: change syntax

* feat: reject invalid features

* feat: add static check of unknown features

* feat: more defensive args handling

* fix: fix typo
2026-03-04 13:32:35 +00:00

77 lines
1.3 KiB
Go

package specs_format_test
import (
"encoding/json"
"math/big"
"testing"
"github.com/formancehq/numscript/internal/interpreter"
"github.com/formancehq/numscript/internal/specs_format"
"github.com/stretchr/testify/require"
)
func TestParseSpecs(t *testing.T) {
raw := `
{
"balances": {
"alice": { "EUR": 200 }
},
"variables": {
"amt": "200"
},
"testCases": [
{
"it": "d1",
"balances": {
"bob": { "EUR": 42 }
},
"expect.postings": [
{
"source": "src",
"destination": "dest",
"asset": "EUR",
"amount": 100
}
]
}
]
}
`
var specs specs_format.Specs
err := json.Unmarshal([]byte(raw), &specs)
require.Nil(t, err)
require.Equal(t, specs_format.Specs{
Balances: interpreter.Balances{
"alice": {
"EUR": big.NewInt(200),
},
},
Vars: interpreter.VariablesMap{
"amt": "200",
},
TestCases: []specs_format.TestCase{
{
It: "d1",
Balances: interpreter.Balances{
"bob": {
"EUR": big.NewInt(42),
},
},
ExpectPostings: []interpreter.Posting{
{
Source: "src",
Destination: "dest",
Asset: "EUR",
Amount: big.NewInt(100),
},
},
},
},
}, specs)
}