-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: workaround wasm coverage issue
Updates: #84 Signed-off-by: Zxilly <[email protected]>
- Loading branch information
Showing
11 changed files
with
223 additions
and
27 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
internal/entity/file_js_wasm.go → internal/entity/file_marshaler.go
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
//go:build js && wasm | ||
//go:build (js && wasm) || test_js_marshaler | ||
|
||
package entity | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
internal/entity/package_js_wasm.go → internal/entity/package_marshaler.go
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
//go:build js && wasm | ||
//go:build (js && wasm) || test_js_marshaler | ||
|
||
package entity | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
internal/entity/section_js_wasm.go → internal/entity/section_marshaler.go
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
//go:build js && wasm | ||
//go:build (js && wasm) || test_js_marshaler | ||
|
||
package entity | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
internal/entity/symbol_js_wasm.go → internal/entity/symbol_marshaler.go
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
//go:build js && wasm | ||
//go:build (js && wasm) || test_js_marshaler | ||
|
||
package entity | ||
|
||
|
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
internal/result/result_js_wasm.go → internal/result/result_marshaler.go
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
//go:build js && wasm | ||
//go:build (js && wasm) || test_js_marshaler | ||
|
||
package result | ||
|
||
|
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,44 @@ | ||
//go:build test_js_marshaler | ||
|
||
package result_test | ||
|
||
import ( | ||
"bytes" | ||
"compress/gzip" | ||
"encoding/gob" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/go-json-experiment/json" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/Zxilly/go-size-analyzer/internal/printer" | ||
"github.com/Zxilly/go-size-analyzer/internal/result" | ||
) | ||
|
||
func TestResult_MarshalJavaScript(t *testing.T) { | ||
testdataGob, err := os.Open(filepath.Join("testdata", "result.gob.gz")) | ||
require.NoError(t, err) | ||
|
||
decompressedReader, err := gzip.NewReader(testdataGob) | ||
require.NoError(t, err) | ||
|
||
r := new(result.Result) | ||
err = gob.NewDecoder(decompressedReader).Decode(r) | ||
require.NoError(t, err) | ||
|
||
jsonPrinterResult := new(bytes.Buffer) | ||
err = printer.JSON(r, &printer.JSONOption{ | ||
HideDetail: true, | ||
Writer: jsonPrinterResult, | ||
}) | ||
require.NoError(t, err) | ||
|
||
resultJSAny := r.MarshalJavaScript() | ||
resultJSJson, err := json.Marshal(resultJSAny) | ||
require.NoError(t, err) | ||
|
||
assert.JSONEq(t, jsonPrinterResult.String(), string(resultJSJson)) | ||
} |
Binary file not shown.
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
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