mirror of
https://github.com/redhat-developer/odo.git
synced 2025-10-19 03:06:19 +03:00
* Create ComponentSettings on `odo create` and apply on `odo push`
This PR does the following:
1. Create Component settings config as part of `odo create` using
the flags passed.
2. As part of `odo push`, if component does not exist:
i. Create it with config created in 1 above
ii. Push source code to created component and build and deploy it
Note: Push now creates project in config if non-existant
else
i. Apply config in local component config file
ii. Push source code to created component and build and deploy it
and update the type of component if config changed
3. Add `context` as a flag to `odo create` and `odo push` to indicate
directory that is expected to contain the component config file.
4. Deprecate application#set, get and create
5. Fixes UTs and e2e relevant to this PR and comments out un-relevant
tests(includign mainly those that are known to broken and expected
to fixed by subsequent issues labelled "new workflow")
e2e credits: amitkrout <amit.silicon2008@gmail.com>
fixes #1366 #1372 #1373
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Fix main and component e2e tests
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Resolved component creation without application
* removed DS store
* fixed component e2e tests
* Fix e2e tests
Commit credits: amitkrout <amit.silicon2008@gmail.com>
Signed-off-by: amitkrout <amit.silicon2008@gmail.com>
* Make project creation test wait for project to appear in list
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Fix more e2e tests
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incoporate @cdrage comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Fix login tests
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* commented out oc project -q to check if it resolves java e2e
97 lines
2.9 KiB
Go
97 lines
2.9 KiB
Go
package project
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/openshift/odo/pkg/occlient"
|
|
"github.com/openshift/odo/pkg/testingutil"
|
|
corev1 "k8s.io/api/core/v1"
|
|
"k8s.io/apimachinery/pkg/runtime"
|
|
"k8s.io/apimachinery/pkg/watch"
|
|
ktesting "k8s.io/client-go/testing"
|
|
"k8s.io/client-go/tools/clientcmd"
|
|
)
|
|
|
|
func TestDelete(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
wantErr bool
|
|
projectName string
|
|
}{
|
|
{
|
|
name: "Test project delete for multiple projects",
|
|
wantErr: false,
|
|
projectName: "prj2",
|
|
},
|
|
{
|
|
name: "Test delete the only remaining project",
|
|
wantErr: false,
|
|
projectName: "testing",
|
|
},
|
|
}
|
|
|
|
odoConfigFile, kubeConfigFile, err := testingutil.SetUp(
|
|
testingutil.ConfigDetails{
|
|
FileName: "odo-test-config",
|
|
Config: testingutil.FakeOdoConfig("odo-test-config", false, ""),
|
|
ConfigPathEnv: "GLOBALODOCONFIG",
|
|
}, testingutil.ConfigDetails{
|
|
FileName: "kube-test-config",
|
|
Config: testingutil.FakeKubeClientConfig(),
|
|
ConfigPathEnv: "KUBECONFIG",
|
|
},
|
|
)
|
|
defer testingutil.CleanupEnv([]*os.File{odoConfigFile, kubeConfigFile}, t)
|
|
if err != nil {
|
|
t.Errorf("failed to create mock odo and kube config files. Error %v", err)
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
// Fake the client with the appropriate arguments
|
|
client, fakeClientSet := occlient.FakeNew()
|
|
|
|
loadingRules := clientcmd.NewDefaultClientConfigLoadingRules()
|
|
configOverrides := &clientcmd.ConfigOverrides{}
|
|
client.KubeConfig = clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, configOverrides)
|
|
|
|
client.Namespace = "testing"
|
|
fkWatch := watch.NewFake()
|
|
|
|
fakeClientSet.ProjClientset.PrependReactor("list", "projects", func(action ktesting.Action) (bool, runtime.Object, error) {
|
|
if tt.name == "Test delete the only remaining project" {
|
|
return true, testingutil.FakeOnlyOneExistingProjects(), nil
|
|
}
|
|
return true, testingutil.FakeProjects(), nil
|
|
})
|
|
|
|
fakeClientSet.ProjClientset.PrependReactor("delete", "projects", func(action ktesting.Action) (bool, runtime.Object, error) {
|
|
return true, nil, nil
|
|
})
|
|
|
|
go func() {
|
|
fkWatch.Delete(testingutil.FakeProjectStatus(corev1.NamespacePhase(""), tt.projectName))
|
|
}()
|
|
fakeClientSet.ProjClientset.PrependWatchReactor("projects", func(action ktesting.Action) (handled bool, ret watch.Interface, err error) {
|
|
return true, fkWatch, nil
|
|
})
|
|
|
|
// The function we are testing
|
|
err := Delete(client, tt.projectName)
|
|
|
|
if err == nil && !tt.wantErr {
|
|
if len(fakeClientSet.ProjClientset.Actions()) != 2 {
|
|
t.Errorf("expected 2 ProjClientSet.Actions() in Project Delete, got: %v", len(fakeClientSet.ProjClientset.Actions()))
|
|
}
|
|
}
|
|
|
|
// Checks for error in positive cases
|
|
if !tt.wantErr == (err != nil) {
|
|
t.Errorf("project Delete() unexpected error %v, wantErr %v", err, tt.wantErr)
|
|
}
|
|
})
|
|
}
|
|
}
|