Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix oc to odo project translation #6949

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions pkg/auth/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,8 @@ func filteredInformation(s []byte) []byte {

// List of strings to correctly filter
s = bytes.Replace(s, []byte("oc new-project"), []byte("odo create project"), -1)
s = bytes.Replace(s, []byte("<projectname>"), []byte("<project-name>"), -1)
s = bytes.Replace(s, []byte("project <project-name>"), []byte("project set <project-name>"), -1)
s = bytes.Replace(s, []byte("odo projects"), []byte("odo list project"), -1)
s = bytes.Replace(s, []byte("oc project "), []byte("odo set project "), -1)
s = bytes.Replace(s, []byte("oc projects"), []byte("odo list project"), -1)

return s
}
78 changes: 78 additions & 0 deletions pkg/auth/login_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package auth

import (
"reflect"
"testing"
)

func Test_filteredInformation(t *testing.T) {
type args struct {
s []byte
}
tests := []struct {
name string
args args
want []byte
}{
{
name: "login with no projects",
args: args{
s: []byte(`Logged into "https://api.crc.testing:6443" as "developer" using existing credentials.

You don't have any projects. You can try to create a new project, by running

oc new-project <projectname>`),
},
want: []byte(`Logged into "https://api.crc.testing:6443" as "developer" using existing credentials.

You don't have any projects. You can try to create a new project, by running

odo create project <projectname>`),
},
{
name: "login with only 1 project",
args: args{
s: []byte(`Logged into "https://api.crc.testing:6443" as "developer" using existing credentials.

You have one project on this server: "test1"

Using project "test1".`),
},
want: []byte(`Logged into "https://api.crc.testing:6443" as "developer" using existing credentials.

You have one project on this server: "test1"

Using project "test1".`),
},
{
name: "login with more than one project",
args: args{
s: []byte(`Logged into "https://api.crc.testing:6443" as "developer" using existing credentials.

You have access to the following projects and can switch between them with 'oc project <projectname>':

test1
test2
* test3

Using project "test3".`),
},
want: []byte(`Logged into "https://api.crc.testing:6443" as "developer" using existing credentials.

You have access to the following projects and can switch between them with 'odo set project <projectname>':

test1
test2
* test3

Using project "test3".`),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := filteredInformation(tt.args.s); !reflect.DeepEqual(got, tt.want) {
t.Errorf("filteredInformation() = %v\nwant = %v", string(got), string(tt.want))
}
})
}
}