(t *testing.T)
| 23 | } |
| 24 | |
| 25 | func TestAreFlagsValid(t *testing.T) { |
| 26 | t.Run("has invalid Repo value", func(t *testing.T) { |
| 27 | opts := baseOptions |
| 28 | opts.Repo = "sigstoresigstore-js" |
| 29 | |
| 30 | err := opts.AreFlagsValid() |
| 31 | require.Error(t, err) |
| 32 | require.ErrorContains(t, err, "invalid value provided for repo") |
| 33 | }) |
| 34 | |
| 35 | t.Run("invalid limit == 0", func(t *testing.T) { |
| 36 | opts := baseOptions |
| 37 | opts.Limit = 0 |
| 38 | |
| 39 | err := opts.AreFlagsValid() |
| 40 | require.Error(t, err) |
| 41 | require.ErrorContains(t, err, "limit 0 not allowed, must be between 1 and 1000") |
| 42 | }) |
| 43 | |
| 44 | t.Run("invalid limit > 1000", func(t *testing.T) { |
| 45 | opts := baseOptions |
| 46 | opts.Limit = 1001 |
| 47 | |
| 48 | err := opts.AreFlagsValid() |
| 49 | require.Error(t, err) |
| 50 | require.ErrorContains(t, err, "limit 1001 not allowed, must be between 1 and 1000") |
| 51 | }) |
| 52 | |
| 53 | t.Run("returns error when UseBundleFromRegistry is true and ArtifactPath is not an OCI path", func(t *testing.T) { |
| 54 | opts := baseOptions |
| 55 | opts.BundlePath = "" |
| 56 | opts.UseBundleFromRegistry = true |
| 57 | |
| 58 | err := opts.AreFlagsValid() |
| 59 | require.Error(t, err) |
| 60 | require.ErrorContains(t, err, "bundle-from-oci flag can only be used with OCI artifact paths") |
| 61 | }) |
| 62 | |
| 63 | t.Run("does not return error when UseBundleFromRegistry is true and ArtifactPath is an OCI path", func(t *testing.T) { |
| 64 | opts := baseOptions |
| 65 | opts.ArtifactPath = "oci://sigstore/sigstore-js:2.1.0" |
| 66 | opts.BundlePath = "" |
| 67 | opts.UseBundleFromRegistry = true |
| 68 | |
| 69 | err := opts.AreFlagsValid() |
| 70 | require.NoError(t, err) |
| 71 | }) |
| 72 | |
| 73 | t.Run("returns error when UseBundleFromRegistry is true and BundlePath is provided", func(t *testing.T) { |
| 74 | opts := baseOptions |
| 75 | opts.ArtifactPath = "oci://sigstore/sigstore-js:2.1.0" |
| 76 | opts.UseBundleFromRegistry = true |
| 77 | |
| 78 | err := opts.AreFlagsValid() |
| 79 | require.Error(t, err) |
| 80 | require.ErrorContains(t, err, "bundle-from-oci flag cannot be used with bundle-path flag") |
| 81 | }) |
| 82 | } |
nothing calls this directly
no test coverage detected