github.com/olli-ai/jx/v2@v2.0.400-0.20210921045218-14731b4dd448/pkg/cmd/step/step_gpg_credentials_test.go (about) 1 // +build unit 2 3 package step_test 4 5 import ( 6 "io/ioutil" 7 "path/filepath" 8 "testing" 9 10 "github.com/olli-ai/jx/v2/pkg/cmd/step" 11 12 "github.com/olli-ai/jx/v2/pkg/tests" 13 "github.com/stretchr/testify/assert" 14 corev1 "k8s.io/api/core/v1" 15 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 16 ) 17 18 func TestStepGPGCredentials(t *testing.T) { 19 t.Parallel() 20 tempDir, err := ioutil.TempDir("", "test-step-gpg") 21 assert.NoError(t, err) 22 23 secret := &corev1.Secret{ 24 ObjectMeta: metav1.ObjectMeta{}, 25 Data: map[string][]byte{ 26 "pubring.gpg": []byte("Pubring"), 27 "sec-jenkins.gpg": []byte("sec jenkins"), 28 "secring.gpg": []byte("secring"), 29 "trustdb.gpg": []byte("trustdb"), 30 }, 31 } 32 33 options := &step.StepGpgCredentialsOptions{ 34 OutputDir: tempDir, 35 } 36 37 err = options.GenerateGpgFiles(secret) 38 assert.NoError(t, err) 39 40 tests.AssertFileExists(t, filepath.Join(tempDir, "pubring.gpg")) 41 tests.AssertFileExists(t, filepath.Join(tempDir, "sec-jenkins.gpg")) 42 tests.AssertFileExists(t, filepath.Join(tempDir, "secring.gpg")) 43 tests.AssertFileExists(t, filepath.Join(tempDir, "trustdb.gpg")) 44 }