diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
commit | 05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch) | |
tree | 11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /workhorse/internal/lsif_transformer/parser/docs_test.go | |
parent | ec73467c23693d0db63a797d10194da9e72a74af (diff) |
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'workhorse/internal/lsif_transformer/parser/docs_test.go')
-rw-r--r-- | workhorse/internal/lsif_transformer/parser/docs_test.go | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/workhorse/internal/lsif_transformer/parser/docs_test.go b/workhorse/internal/lsif_transformer/parser/docs_test.go index 24e3eba8ac5..805bc53c0b7 100644 --- a/workhorse/internal/lsif_transformer/parser/docs_test.go +++ b/workhorse/internal/lsif_transformer/parser/docs_test.go @@ -18,16 +18,32 @@ func TestParse(t *testing.T) { require.NoError(t, err) defer d.Close() - data := []byte(`{"id":"1","label":"metaData","projectRoot":"file:///Users/nested"}` + "\n") - data = append(data, createLine("2", "document", "file:///Users/nested/file.rb")...) - data = append(data, createLine("3", "document", "file:///Users/nested/folder/file.rb")...) - data = append(data, createLine("4", "document", "file:///Users/wrong/file.rb")...) + for _, root := range []string{ + "file:///Users/nested", + "file:///Users/nested/.", + "file:///Users/nested/", + } { + t.Run("Document with root: "+root, func(t *testing.T) { + data := []byte(`{"id":"1","label":"metaData","projectRoot":"` + root + `"}` + "\n") + data = append(data, createLine("2", "document", "file:///Users/nested/file.rb")...) + data = append(data, createLine("3", "document", "file:///Users/nested/folder/file.rb")...) - require.NoError(t, d.Parse(bytes.NewReader(data))) + require.NoError(t, d.Parse(bytes.NewReader(data))) + + require.Equal(t, "file.rb", d.Entries[2]) + require.Equal(t, "folder/file.rb", d.Entries[3]) + }) + } + + t.Run("Relative path cannot be calculated", func(t *testing.T) { + originalUri := "file:///Users/nested/folder/file.rb" + data := []byte(`{"id":"1","label":"metaData","projectRoot":"/a"}` + "\n") + data = append(data, createLine("2", "document", originalUri)...) + + require.NoError(t, d.Parse(bytes.NewReader(data))) - require.Equal(t, d.Entries[2], "file.rb") - require.Equal(t, d.Entries[3], "folder/file.rb") - require.Equal(t, d.Entries[4], "file:///Users/wrong/file.rb") + require.Equal(t, originalUri, d.Entries[2]) + }) } func TestParseContainsLine(t *testing.T) { |