package main import ( "bytes" "testing" "git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/handler" "github.com/stretchr/testify/require" ) func TestDefaultNamespace(t *testing.T) { xmlBodyWithNamespace := ` string 1 ` xmlBodyWithInvalidNamespace := ` string 1 ` xmlBody := ` string 1 ` for _, tc := range []struct { settings *appSettings input string err bool }{ { settings: &appSettings{ defaultXMLNSForCompleteMultipart: false, }, input: xmlBodyWithNamespace, err: false, }, { settings: &appSettings{ defaultXMLNSForCompleteMultipart: false, }, input: xmlBody, err: true, }, { settings: &appSettings{ defaultXMLNSForCompleteMultipart: false, }, input: xmlBodyWithInvalidNamespace, err: true, }, { settings: &appSettings{ defaultXMLNSForCompleteMultipart: true, }, input: xmlBodyWithNamespace, err: false, }, { settings: &appSettings{ defaultXMLNSForCompleteMultipart: true, }, input: xmlBody, err: false, }, { settings: &appSettings{ defaultXMLNSForCompleteMultipart: true, }, input: xmlBodyWithInvalidNamespace, err: true, }, } { t.Run("", func(t *testing.T) { model := new(handler.CompleteMultipartUpload) err := tc.settings.NewCompleteMultipartDecoder(bytes.NewBufferString(tc.input)).Decode(model) if tc.err { require.Error(t, err) } else { require.NoError(t, err) } }) } }