aboutsummaryrefslogtreecommitdiffstats
path: root/client/go/internal/vespa/id_test.go
blob: 8343332e84134aed032722d0226fa04b3c0936f6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package vespa

import (
	"testing"

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

func TestIdToURLPath(t *testing.T) {
	assertIdToURLPath("ns/type/docid/local", "id:ns:type::local", t)
	assertIdToURLPath("ns/type/number/123/docid/local", "id:ns:type:n=123:local", t)
	assertIdToURLPath("ns/type/group/mygroup/docid/local", "id:ns:type:g=mygroup:local", t)
}

func assertIdToURLPath(expectedPath string, id string, t *testing.T) {
	path, err := IdToURLPath(id)
	assert.Nil(t, err)
	assert.Equal(t, expectedPath, path)
}