Implemented the remaining trim artifact cleanup
All checks were successful
ci/woodpecker/tag/release Pipeline was successful
All checks were successful
ci/woodpecker/tag/release Pipeline was successful
This commit is contained in:
@@ -128,6 +128,61 @@ func TestConvertArtifactMinimalToFullFails(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateArtifactRejectsMissingPayloads(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
artifact Artifact
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "full",
|
||||
artifact: Artifact{Schema: SchemaFull},
|
||||
want: "full artifact payload is missing",
|
||||
},
|
||||
{
|
||||
name: "intermediate",
|
||||
artifact: Artifact{Schema: SchemaIntermediate},
|
||||
want: "intermediate artifact payload is missing",
|
||||
},
|
||||
{
|
||||
name: "minimal",
|
||||
artifact: Artifact{Schema: SchemaMinimal},
|
||||
want: "minimal artifact payload is missing",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
err := ValidateArtifact(test.artifact)
|
||||
assertErrorContains(t, err, test.want)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestApplyArtifactRejectsMissingPayload(t *testing.T) {
|
||||
_, err := ApplyArtifact(Artifact{Schema: SchemaFull}, Options{})
|
||||
assertErrorContains(t, err, "full artifact payload is missing")
|
||||
}
|
||||
|
||||
func TestConvertArtifactRejectsMissingPayloadWhenConversionRequested(t *testing.T) {
|
||||
_, err := ConvertArtifact(Artifact{Schema: SchemaFull}, SchemaMinimal)
|
||||
assertErrorContains(t, err, "full artifact payload is missing")
|
||||
}
|
||||
|
||||
func TestConvertArtifactSameSchemaDoesNotRequirePayload(t *testing.T) {
|
||||
artifact := Artifact{Schema: SchemaFull}
|
||||
converted, err := ConvertArtifact(artifact, SchemaFull)
|
||||
if err != nil {
|
||||
t.Fatalf("convert failed: %v", err)
|
||||
}
|
||||
if converted.Schema != SchemaFull {
|
||||
t.Fatalf("schema = %q, want %q", converted.Schema, SchemaFull)
|
||||
}
|
||||
if converted.Full != nil {
|
||||
t.Fatalf("full payload = %#v, want nil", converted.Full)
|
||||
}
|
||||
}
|
||||
|
||||
func mustMarshalJSON(t *testing.T, value any) []byte {
|
||||
t.Helper()
|
||||
data, err := json.Marshal(value)
|
||||
|
||||
Reference in New Issue
Block a user