Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to access a URL through canvas.NewImageFromURI() in a test results in a panic #4863

Closed
2 tasks done
ErikKalkoken opened this issue May 22, 2024 · 2 comments
Closed
2 tasks done
Labels
bug Something isn't working

Comments

@ErikKalkoken
Copy link
Contributor

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

When trying to access a URL through canvas.NewImageFromURI() in a test I am getting a panic.

This works fine in normal app code though.

This is the error message:

2024/05/22 15:14:29 Fyne error:  Failed to open image URI
2024/05/22 15:14:29   Cause: no repository registered for scheme 'https'
2024/05/22 15:14:29   At: /home/erik/go/pkg/mod/fyne.io/fyne/v2@v2.4.5/canvas/image.go:215

How to reproduce

Run a test with the below example code.

Screenshots

No response

Example code

Here is a minimal code example to reproduce this behavior:

package images_test

import (
    "testing"

    "fyne.io/fyne/v2/canvas"
    "fyne.io/fyne/v2/storage"
)

func TestImage(t *testing.T) {
    uri := "https://images.evetech.net/characters/93330670/portrait?size=64"
    u, err := storage.ParseURI(uri)
    if err != nil {
        panic(err)
    }
    image := canvas.NewImageFromURI(u)
    r := image.Resource
    r.Content()
}

Fyne version

2.4.5

Go compiler version

1.22.1

Operating system and version

Ubuntu 22.04.4 LTS

Additional Information

Andy mentioned on Discord that the cause might be that http/https is not mounted for storage in the test runner and suggested to open a bug report to change that.

https://discord.com/channels/953020122690359327/953030515152281650/1242832020745359392

@ErikKalkoken ErikKalkoken added the unverified A bug that has been reported but not verified label May 22, 2024
andydotxyz added a commit to andydotxyz/fyne that referenced this issue May 22, 2024
@andydotxyz
Copy link
Member

The fix is now on the linked PR.
Note that you should import the Fyne test helpers to get all the lookups registered:

import _ "fyne.io/fyne/v2/test"

@andydotxyz andydotxyz added bug Something isn't working and removed unverified A bug that has been reported but not verified labels May 23, 2024
@andydotxyz
Copy link
Member

Resolved on the develop branch and ready for v2.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants