Skip to content

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

Closed
@ErikKalkoken

Description

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/[email protected]/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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions