snapshot of https://github.com/cortezaproject/corteza.git (2024.9.x, 2026-09-18; blobs > 131072B omitted)
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
This commit is contained in:
72
server/pkg/envoyx/json/decoder_test.go
Normal file
72
server/pkg/envoyx/json/decoder_test.go
Normal file
@@ -0,0 +1,72 @@
|
||||
package json
|
||||
|
||||
import (
|
||||
"io"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/cortezaproject/corteza/server/pkg/envoyx/datasource"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestDecoder(t *testing.T) {
|
||||
req := require.New(t)
|
||||
|
||||
t.Run("init & meta", func(t *testing.T) {
|
||||
dc, err := Decoder(testReader(), "test.csv")
|
||||
req.NoError(err)
|
||||
|
||||
req.Equal(uint64(3), dc.Count())
|
||||
})
|
||||
|
||||
t.Run("fields", func(t *testing.T) {
|
||||
dc, err := Decoder(testReader(), "test.csv")
|
||||
req.NoError(err)
|
||||
|
||||
hh := dc.Fields()
|
||||
req.Contains(hh, "f1")
|
||||
req.Contains(hh, "f2")
|
||||
req.Contains(hh, "f3")
|
||||
})
|
||||
|
||||
t.Run("iterate", func(t *testing.T) {
|
||||
dc, err := Decoder(testReader(), "test.csv")
|
||||
req.NoError(err)
|
||||
|
||||
aux := make(datasource.RawRecord)
|
||||
var more bool
|
||||
|
||||
more, err = dc.Next(nil, aux)
|
||||
req.NoError(err)
|
||||
req.True(more)
|
||||
req.Equal("r1f1", aux["f1"].Values[0])
|
||||
req.Equal("r1f2", aux["f2"].Values[0])
|
||||
req.Equal("r1f3", aux["f3"].Values[0])
|
||||
|
||||
more, err = dc.Next(nil, aux)
|
||||
req.NoError(err)
|
||||
req.True(more)
|
||||
req.Equal("r2f1", aux["f1"].Values[0])
|
||||
req.Equal("r2f2", aux["f2"].Values[0])
|
||||
req.Equal("r2f3", aux["f3"].Values[0])
|
||||
|
||||
more, err = dc.Next(nil, aux)
|
||||
req.NoError(err)
|
||||
req.True(more)
|
||||
req.Equal("r3f1", aux["f1"].Values[0])
|
||||
req.Equal("r3f2", aux["f2"].Values[0])
|
||||
req.Equal("r3f3", aux["f3"].Values[0])
|
||||
|
||||
more, err = dc.Next(nil, aux)
|
||||
req.NoError(err)
|
||||
req.False(more)
|
||||
})
|
||||
}
|
||||
|
||||
func testReader() io.Reader {
|
||||
src := `{"f1": "r1f1", "f2": "r1f2", "f3": "r1f3"}
|
||||
{"f1": "r2f1", "f2": "r2f2", "f3": "r2f3"}
|
||||
{"f1": "r3f1", "f2": "r3f2", "f3": "r3f3"}`
|
||||
|
||||
return strings.NewReader(src)
|
||||
}
|
||||
Reference in New Issue
Block a user