fix(sitecore): replace HasFiles with HasFilesInDir
Some checks are pending
Code QL / code-ql (push) Waiting to run
Release / changelog (push) Waiting to run
Release / artifacts (push) Blocked by required conditions

This commit is contained in:
Bohdan Dorokhin 2024-08-13 09:21:55 +03:00 committed by GitHub
parent 8ff47c7f65
commit 67deabffda
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 8 additions and 22 deletions

View file

@ -33,13 +33,15 @@ type UserConfig struct {
}
func (s *Sitecore) Enabled() bool {
if !s.env.HasFiles(sitecoreFileName) || !s.env.HasFiles(path.Join(sitecoreFolderName, userFileName)) {
if !s.env.HasFiles(sitecoreFileName) || !s.env.HasFilesInDir(sitecoreFolderName, userFileName) {
s.env.Debug("sitecore cli configuration files were not found")
return false
}
var userConfig, err = getUserConfig(s)
if err != nil {
s.env.Error(err)
return false
}
@ -48,6 +50,7 @@ func (s *Sitecore) Enabled() bool {
displayDefault := s.props.GetBool(properties.DisplayDefault, true)
if !displayDefault && s.EndpointName == defaultEnpointName {
s.env.Debug("displaying of the default environment is turned off")
return false
}

View file

@ -8,6 +8,7 @@ import (
"github.com/jandedobbeleer/oh-my-posh/src/runtime/mock"
"github.com/stretchr/testify/assert"
testify_ "github.com/stretchr/testify/mock"
)
func TestSitecoreSegment(t *testing.T) {
@ -86,8 +87,10 @@ func TestSitecoreSegment(t *testing.T) {
for _, tc := range cases {
env := new(mock.Environment)
env.On("HasFiles", "sitecore.json").Return(tc.SitecoreFileExists)
env.On("HasFiles", path.Join(".sitecore", "user.json")).Return(tc.UserFileExists)
env.On("HasFilesInDir", ".sitecore", "user.json").Return(tc.UserFileExists)
env.On("FileContent", path.Join(".sitecore", "user.json")).Return(tc.UserFileContent)
env.On("Debug", testify_.Anything)
env.On("Error", testify_.Anything)
props := properties.Map{
properties.DisplayDefault: tc.DisplayDefault,

View file

@ -1,10 +0,0 @@
{
"endpoints": {
"default": {
"ref": "xmcloud",
"allowWrite": true,
"host": "https://xmc-sitecore<someID>-projectName-environmentName.sitecorecloud.io",
"variables": {}
}
}
}

View file

@ -1,10 +0,0 @@
{
"endpoints": {
"default": {
"ref": "local",
"allowWrite": true,
"host": "https://xmcloudcm.local",
"variables": {}
}
}
}