-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework reader usage and fix loading dropped file
- Loading branch information
1 parent
41c5880
commit 76b2fc3
Showing
10 changed files
with
91 additions
and
89 deletions.
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,24 @@ | ||
package jsondocument | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
|
||
"fyne.io/fyne/v2" | ||
"fyne.io/fyne/v2/storage" | ||
) | ||
|
||
// Creates and returns an URIReadCloser from a reader. | ||
func MakeURIReadCloser(r io.Reader, name string) uriReadCloser { | ||
return uriReadCloser{io.NopCloser(r), name} | ||
} | ||
|
||
type uriReadCloser struct { | ||
io.ReadCloser | ||
name string | ||
} | ||
|
||
func (u uriReadCloser) URI() fyne.URI { | ||
uri, _ := storage.ParseURI(fmt.Sprintf("dummy://dummy/%s", u.name)) | ||
return uri | ||
} |
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,15 @@ | ||
package jsondocument_test | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
"github.com/ErikKalkoken/jsonviewer/internal/jsondocument" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestHelper(t *testing.T) { | ||
r := strings.NewReader("test") | ||
r2 := jsondocument.MakeURIReadCloser(r, "alpha") | ||
assert.Equal(t, "alpha", r2.URI().Name()) | ||
} |
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
This file was deleted.
Oops, something went wrong.
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