github.com/jfrog/jfrog-cli-core/v2@v2.51.0/artifactory/commands/npm/publish_test.go (about) 1 package npm 2 3 import ( 4 "path/filepath" 5 "testing" 6 7 "github.com/stretchr/testify/assert" 8 ) 9 10 func TestReadPackageInfoFromTarball(t *testing.T) { 11 npmPublish := NewNpmPublishCommand() 12 13 var testCases = []struct { 14 filePath string 15 packageName string 16 packageVersion string 17 }{ 18 { 19 filePath: filepath.Join("..", "testdata", "npm", "npm-example-0.0.3.tgz"), 20 packageName: "npm-example", 21 packageVersion: "0.0.3", 22 }, { 23 filePath: filepath.Join("..", "testdata", "npm", "npm-example-0.0.4.tgz"), 24 packageName: "npm-example", 25 packageVersion: "0.0.4", 26 }, 27 } 28 for _, test := range testCases { 29 err := npmPublish.readPackageInfoFromTarball(test.filePath) 30 assert.NoError(t, err) 31 assert.Equal(t, test.packageName, npmPublish.packageInfo.Name) 32 assert.Equal(t, test.packageVersion, npmPublish.packageInfo.Version) 33 } 34 }