File: url_test.go

package info (click to toggle)
golang-github-anacrolix-missinggo 2.1.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 836 kB
  • sloc: makefile: 4
file content (21 lines) | stat: -rw-r--r-- 711 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package missinggo

import (
	"net/url"
	"testing"

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

func TestURLOpaquePath(t *testing.T) {
	assert.Equal(t, "sqlite3://sqlite3.db", (&url.URL{Scheme: "sqlite3", Path: "sqlite3.db"}).String())
	u, err := url.Parse("sqlite3:sqlite3.db")
	assert.NoError(t, err)
	assert.Equal(t, "sqlite3.db", URLOpaquePath(u))
	assert.Equal(t, "sqlite3:sqlite3.db", (&url.URL{Scheme: "sqlite3", Opaque: "sqlite3.db"}).String())
	assert.Equal(t, "sqlite3:/sqlite3.db", (&url.URL{Scheme: "sqlite3", Opaque: "/sqlite3.db"}).String())
	u, err = url.Parse("sqlite3:/sqlite3.db")
	assert.NoError(t, err)
	assert.Equal(t, "/sqlite3.db", u.Path)
	assert.Equal(t, "/sqlite3.db", URLOpaquePath(u))
}