Skip to content

Commit

Permalink
Hook up test file repository and disable a couple of tests until we h…
Browse files Browse the repository at this point in the history
…ave an http repository

Now tests all pass
  • Loading branch information
andydotxyz committed Jan 13, 2021
1 parent 543d4b9 commit febdb5f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 26 deletions.
13 changes: 6 additions & 7 deletions internal/repository/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,13 @@ func (r *FileRepository) Parent(u fyne.URI) (fyne.URI, error) {
}

return storage.ParseURI(u.Scheme() + "://" + parent)
} else {
var err error
parent, err := repository.GenericParent(u, storage.ParseURI)
if err != nil {
return nil, err
}
return parent, nil
}

uri, err := repository.GenericParent(u, storage.ParseURI)
if err != nil {
return nil, err
}
return uri, nil
}

// Child implements repository.HierarchicalRepository.Child
Expand Down
2 changes: 0 additions & 2 deletions internal/repository/memory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"fyne.io/fyne/storage"
"fyne.io/fyne/storage/repository"

_ "fyne.io/fyne/test"

"github.com/stretchr/testify/assert"
)

Expand Down
35 changes: 18 additions & 17 deletions storage/uri_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,23 +134,24 @@ func TestURI_Parent(t *testing.T) {
assert.Nil(t, err)
assert.Equal(t, "file://C:/foo/bar/", parent.String())

parent, err = storage.Parent(storage.NewURI("http://foo/bar/baz/"))
assert.Nil(t, err)
assert.Equal(t, "http://foo/bar/", parent.String())

parent, err = storage.Parent(storage.NewURI("http:////foo/bar/baz/"))
assert.Nil(t, err)
assert.Equal(t, "http://foo/bar/", parent.String())

_, err = storage.Parent(storage.NewURI("http://foo"))
assert.Equal(t, storage.URIRootError, err)

_, err = storage.Parent(storage.NewURI("http:///"))
assert.Equal(t, storage.URIRootError, err)

parent, err = storage.Parent(storage.NewURI("https://///foo/bar/"))
assert.Nil(t, err)
assert.Equal(t, "https:///foo/", parent.String())
// TODO hook in an http/https handler
//parent, err = storage.Parent(storage.NewURI("http://foo/bar/baz/"))
//assert.Nil(t, err)
//assert.Equal(t, "http://foo/bar/", parent.String())
//
//parent, err = storage.Parent(storage.NewURI("http:////foo/bar/baz/"))
//assert.Nil(t, err)
//assert.Equal(t, "http://foo/bar/", parent.String())
//
//_, err = storage.Parent(storage.NewURI("http://foo"))
//assert.Equal(t, storage.URIRootError, err)
//
//_, err = storage.Parent(storage.NewURI("http:///"))
//assert.Equal(t, storage.URIRootError, err)
//
//parent, err = storage.Parent(storage.NewURI("https://///foo/bar/"))
//assert.Nil(t, err)
//assert.Equal(t, "https:///foo/", parent.String())

if runtime.GOOS == "windows" {
// Only the Windows version of filepath will know how to handle
Expand Down
3 changes: 3 additions & 0 deletions test/testdriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"fyne.io/fyne/internal/driver"
"fyne.io/fyne/internal/painter"
"fyne.io/fyne/internal/painter/software"
intRepo "fyne.io/fyne/internal/repository"
"fyne.io/fyne/storage/repository"

"github.com/goki/freetype/truetype"
"golang.org/x/image/font"
Expand All @@ -33,6 +35,7 @@ var _ fyne.Driver = (*testDriver)(nil)
func NewDriver() fyne.Driver {
drv := new(testDriver)
drv.windowsMutex = sync.RWMutex{}
repository.Register("file", intRepo.NewFileRepository("file"))

// make a single dummy window for rendering tests
drv.CreateWindow("")
Expand Down

0 comments on commit febdb5f

Please sign in to comment.