File: fetch_test.go

package info (click to toggle)
cfrpki 1.4.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,960 kB
  • sloc: makefile: 73; sh: 34
file content (38 lines) | stat: -rw-r--r-- 928 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
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package syncpki

import (
	"testing"

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

func TestGetLocalPath(t *testing.T) {
	tests := []struct {
		name     string
		pathRep  string
		replace  map[string]string
		expected string
	}{
		{
			name:    "With trailing slash",
			pathRep: "rsync://rpki.apnic.net/repository/apnic-rpki-root-iana-origin.cer",
			replace: map[string]string{
				"rsync://": "cache/",
			},
			expected: "cache/rpki.apnic.net/repository/apnic-rpki-root-iana-origin.cer",
		},
		{
			name:    "Without trailing slash (this is a regresion test)",
			pathRep: "rsync://rpki.apnic.net/repository/apnic-rpki-root-iana-origin.cer",
			replace: map[string]string{
				"rsync://": "cache",
			},
			expected: "cache/rpki.apnic.net/repository/apnic-rpki-root-iana-origin.cer",
		},
	}

	for _, test := range tests {
		res := GetLocalPath(test.pathRep, test.replace)
		assert.Equal(t, test.expected, res, test.name)
	}
}