mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-01-22 08:31:14 -08:00
37 lines
803 B
Go
37 lines
803 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/alecthomas/assert"
|
||
|
)
|
||
|
|
||
|
func TestNodeMatchesVersionFile(t *testing.T) {
|
||
|
cases := []struct {
|
||
|
Case string
|
||
|
Expected bool
|
||
|
RCVersion string
|
||
|
Version string
|
||
|
}{
|
||
|
{Case: "no file context", Expected: true, RCVersion: "", Version: "durp"},
|
||
|
{Case: "version match", Expected: true, RCVersion: "durp", Version: "durp"},
|
||
|
{Case: "version mismatch", Expected: false, RCVersion: "werp", Version: "durp"},
|
||
|
}
|
||
|
|
||
|
for _, tc := range cases {
|
||
|
env := new(MockedEnvironment)
|
||
|
env.On("getFileContent", ".nvmrc").Return(tc.RCVersion)
|
||
|
node := &node{
|
||
|
language: &language{
|
||
|
env: env,
|
||
|
activeCommand: &cmd{
|
||
|
version: &version{
|
||
|
full: tc.Version,
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
}
|
||
|
assert.Equal(t, tc.Expected, node.matchesVersionFile(), tc.Case)
|
||
|
}
|
||
|
}
|