Test Failed
Pull Request — main (#73)
by Igor
01:52
created

path_test.go   A

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 17
dl 0
loc 28
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A validation_test.TestPropertyPath_String 0 7 1
A validation_test.TestPropertyPath_With 0 10 1
1
package validation_test
2
3
import (
4
	"testing"
5
6
	"github.com/muonsoft/validation"
7
	"github.com/stretchr/testify/assert"
8
)
9
10
func TestPropertyPath_String(t *testing.T) {
11
	var path *validation.PropertyPath
12
	path = path.WithProperty("array").WithIndex(1).WithProperty("property")
13
14
	formatted := path.String()
15
16
	assert.Equal(t, "array[1].property", formatted)
17
}
18
19
func TestPropertyPath_With(t *testing.T) {
20
	path := validation.NewPropertyPath(validation.PropertyNameElement("top"), validation.ArrayIndexElement(0))
21
22
	path = path.With(
23
		validation.PropertyNameElement("low"),
24
		validation.ArrayIndexElement(1),
25
		validation.PropertyNameElement("property"),
26
	)
27
28
	assert.Equal(t, "top[0].low[1].property", path.String())
29
}
30