github.com/terraform-linters/tflint@v0.51.2-0.20240520175844-3750771571b6/langserver/handler_test.go (about)

     1  package langserver
     2  
     3  import (
     4  	"runtime"
     5  	"testing"
     6  
     7  	"github.com/google/go-cmp/cmp"
     8  	lsp "github.com/sourcegraph/go-lsp"
     9  )
    10  
    11  func Test_uriToPath_windows(t *testing.T) {
    12  	if runtime.GOOS != "windows" {
    13  		return
    14  	}
    15  
    16  	uri := lsp.DocumentURI("file:///c%3A/example%20directory")
    17  	value, _ := uriToPath(uri)
    18  	expected := "c:/example directory"
    19  
    20  	if !cmp.Equal(expected, value) {
    21  		t.Fatalf("Diff: %s", cmp.Diff(expected, value))
    22  	}
    23  }
    24  
    25  func Test_uriToPath_others(t *testing.T) {
    26  	if runtime.GOOS == "windows" {
    27  		return
    28  	}
    29  
    30  	uri := lsp.DocumentURI("file:///example%20directory")
    31  	value, _ := uriToPath(uri)
    32  	expected := "/example directory"
    33  
    34  	if !cmp.Equal(expected, value) {
    35  		t.Fatalf("Diff: %s", cmp.Diff(expected, value))
    36  	}
    37  }