Skip to content

Commit

Permalink
fix: fix hover test with result nil
Browse files Browse the repository at this point in the history
  • Loading branch information
qvalentin committed Nov 2, 2024
1 parent 3210f63 commit c628b01
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 3 deletions.
7 changes: 4 additions & 3 deletions internal/handler/hover_main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,11 @@ func TestHoverMain(t *testing.T) {
},
})
assert.Equal(t, tt.expectedError, err)
if result == nil {
t.Fatal("Result is nil")
if tt.expected == "" {
assert.Nil(t, result)
} else {
assert.Equal(t, tt.expected, strings.ReplaceAll(result.Contents.Value, "\r\n", "\n"))
}
assert.Equal(t, tt.expected, strings.ReplaceAll(result.Contents.Value, "\r\n", "\n"))
})
}
}
45 changes: 45 additions & 0 deletions internal/util/goccy_yaml_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package util

import (
"testing"

"github.com/goccy/go-yaml/lexer"

Check failure on line 6 in internal/util/goccy_yaml_test.go

View workflow job for this annotation

GitHub Actions / tests (1.22.4, ubuntu-latest)

no required module provides package github.com/goccy/go-yaml/lexer; to add it:

Check failure on line 6 in internal/util/goccy_yaml_test.go

View workflow job for this annotation

GitHub Actions / tests (1.22.4, ubuntu-latest)

no required module provides package github.com/goccy/go-yaml/lexer; to add it:

Check failure on line 6 in internal/util/goccy_yaml_test.go

View workflow job for this annotation

GitHub Actions / tests (1.22.4, ubuntu-latest)

no required module provides package github.com/goccy/go-yaml/lexer; to add it:

Check failure on line 6 in internal/util/goccy_yaml_test.go

View workflow job for this annotation

GitHub Actions / tests (1.22.4, macos-latest)

no required module provides package github.com/goccy/go-yaml/lexer; to add it:

Check failure on line 6 in internal/util/goccy_yaml_test.go

View workflow job for this annotation

GitHub Actions / tests (1.22.4, macos-latest)

no required module provides package github.com/goccy/go-yaml/lexer; to add it:

Check failure on line 6 in internal/util/goccy_yaml_test.go

View workflow job for this annotation

GitHub Actions / tests (1.22.4, macos-latest)

no required module provides package github.com/goccy/go-yaml/lexer; to add it:

Check failure on line 6 in internal/util/goccy_yaml_test.go

View workflow job for this annotation

GitHub Actions / tests (1.22.4, windows-2022)

no required module provides package github.com/goccy/go-yaml/lexer; to add it:

Check failure on line 6 in internal/util/goccy_yaml_test.go

View workflow job for this annotation

GitHub Actions / tests (1.22.4, windows-2022)

no required module provides package github.com/goccy/go-yaml/lexer; to add it:
"github.com/goccy/go-yaml/parser"
)

var brokenYaml = `
this: isSomeYmal
imCurrentlyTypinghere: dsa
baz:
imCurrentlyTypinghere
isNested: Yaml
baz2:
with: Brokf
`

func TestLexer(t *testing.T) {
got := lexer.Tokenize(brokenYaml)

for _, token := range got {
t.Log(token.Type, token.Position.String())
}

t.Log(got)
t.Fail()
}

func TestParser(t *testing.T) {
tokens := lexer.Tokenize(brokenYaml)
got, err := parser.Parse(tokens, parser.ParseComments)
if got == nil {
t.Fatal(err)
}

nodes := got.Docs

for _, node := range nodes {
t.Log(node.Type(), node.String())
}

t.Fail()
}

0 comments on commit c628b01

Please sign in to comment.