27 lines
528 B
Go
27 lines
528 B
Go
package python
|
|
|
|
import "testing"
|
|
|
|
var pathTests = []struct {
|
|
input string
|
|
expected string
|
|
}{
|
|
{"", "."},
|
|
{"../", ".."},
|
|
{"../..", "..."},
|
|
{"../../..", "...."},
|
|
{"something", ".something"},
|
|
{"../parent", "..parent"},
|
|
{"../../module", "...module"},
|
|
}
|
|
|
|
func TestRelPathToRelImport(t *testing.T) {
|
|
for _, tt := range pathTests {
|
|
t.Run(tt.input, func(t *testing.T) {
|
|
result := relPathToRelImport(tt.input)
|
|
if result != tt.expected {
|
|
t.Errorf("expected \"%s\"; got \"%s\"", tt.expected, result)
|
|
}
|
|
})
|
|
}
|
|
}
|