mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-03 14:54:53 -04:00
cli: create or read state file during constellation create
(#2470)
Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
parent
1a141c3972
commit
fe7e16e1cc
4 changed files with 128 additions and 88 deletions
|
@ -72,14 +72,14 @@ func TestCreate(t *testing.T) {
|
|||
},
|
||||
"interactive abort": {
|
||||
setupFs: fsWithDefaultConfigAndState,
|
||||
creator: &stubCloudCreator{},
|
||||
creator: &stubCloudCreator{state: infraState},
|
||||
provider: cloudprovider.GCP,
|
||||
stdin: "no\n",
|
||||
wantAbort: true,
|
||||
},
|
||||
"interactive error": {
|
||||
setupFs: fsWithDefaultConfigAndState,
|
||||
creator: &stubCloudCreator{},
|
||||
creator: &stubCloudCreator{state: infraState},
|
||||
provider: cloudprovider.GCP,
|
||||
stdin: "foo\nfoo\nfoo\n",
|
||||
wantErr: true,
|
||||
|
@ -92,7 +92,7 @@ func TestCreate(t *testing.T) {
|
|||
require.NoError(fileHandler.WriteYAML(constants.ConfigFilename, defaultConfigWithExpectedMeasurements(t, config.Default(), csp)))
|
||||
return fs
|
||||
},
|
||||
creator: &stubCloudCreator{},
|
||||
creator: &stubCloudCreator{state: infraState},
|
||||
provider: cloudprovider.GCP,
|
||||
yesFlag: true,
|
||||
wantErr: true,
|
||||
|
@ -105,24 +105,23 @@ func TestCreate(t *testing.T) {
|
|||
require.NoError(fileHandler.WriteYAML(constants.ConfigFilename, defaultConfigWithExpectedMeasurements(t, config.Default(), csp)))
|
||||
return fs
|
||||
},
|
||||
creator: &stubCloudCreator{},
|
||||
creator: &stubCloudCreator{state: infraState},
|
||||
provider: cloudprovider.GCP,
|
||||
yesFlag: true,
|
||||
wantErr: true,
|
||||
},
|
||||
"config does not exist": {
|
||||
setupFs: func(a *require.Assertions, p cloudprovider.Provider) afero.Fs { return afero.NewMemMapFs() },
|
||||
creator: &stubCloudCreator{},
|
||||
creator: &stubCloudCreator{state: infraState},
|
||||
provider: cloudprovider.GCP,
|
||||
yesFlag: true,
|
||||
wantErr: true,
|
||||
},
|
||||
"state file does not exist": {
|
||||
setupFs: fsWithoutState,
|
||||
creator: &stubCloudCreator{},
|
||||
creator: &stubCloudCreator{state: infraState},
|
||||
provider: cloudprovider.GCP,
|
||||
yesFlag: true,
|
||||
wantErr: true,
|
||||
},
|
||||
"create error": {
|
||||
setupFs: fsWithDefaultConfigAndState,
|
||||
|
@ -131,14 +130,14 @@ func TestCreate(t *testing.T) {
|
|||
yesFlag: true,
|
||||
wantErr: true,
|
||||
},
|
||||
"write id file error": {
|
||||
"write state file error": {
|
||||
setupFs: func(require *require.Assertions, csp cloudprovider.Provider) afero.Fs {
|
||||
fs := afero.NewMemMapFs()
|
||||
fileHandler := file.NewHandler(fs)
|
||||
require.NoError(fileHandler.WriteYAML(constants.ConfigFilename, defaultConfigWithExpectedMeasurements(t, config.Default(), csp)))
|
||||
return afero.NewReadOnlyFs(fs)
|
||||
},
|
||||
creator: &stubCloudCreator{},
|
||||
creator: &stubCloudCreator{state: infraState},
|
||||
provider: cloudprovider.GCP,
|
||||
yesFlag: true,
|
||||
wantErr: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue