Skip to content
Snippets Groups Projects
Unverified Commit d58efa34 authored by dlorenc's avatar dlorenc Committed by GitHub
Browse files

Deduplicate some test logic. (#554)


This was duplicated across the unit tests for all of our types, moved it
up to the top-level package.

Signed-off-by: default avatarDan Lorenc <lorenc.d@gmail.com>
parent 06538859
No related branches found
No related tags found
No related merge requests found
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
package alpine package alpine
import ( import (
"context"
"errors" "errors"
"testing" "testing"
...@@ -28,50 +27,11 @@ import ( ...@@ -28,50 +27,11 @@ import (
type UnmarshalTester struct { type UnmarshalTester struct {
models.Alpine models.Alpine
} types.BaseUnmarshalTester
func (u UnmarshalTester) NewEntry() types.EntryImpl {
return &UnmarshalTester{}
}
func (u UnmarshalTester) APIVersion() string {
return "2.0.1"
}
func (u UnmarshalTester) IndexKeys() ([]string, error) {
return []string{}, nil
}
func (u UnmarshalTester) Canonicalize(ctx context.Context) ([]byte, error) {
return nil, nil
}
func (u UnmarshalTester) HasExternalEntities() bool {
return false
}
func (u *UnmarshalTester) FetchExternalEntities(ctx context.Context) error {
return nil
}
func (u UnmarshalTester) Unmarshal(pe models.ProposedEntry) error {
return nil
}
func (u UnmarshalTester) Validate() error {
return nil
}
func (u UnmarshalTester) Attestation() (string, []byte) {
return "", nil
}
func (u UnmarshalTester) CreateFromArtifactProperties(_ context.Context, _ types.ArtifactProperties) (models.ProposedEntry, error) {
return nil, nil
} }
type UnmarshalFailsTester struct { type UnmarshalFailsTester struct {
UnmarshalTester types.BaseUnmarshalTester
} }
func (u UnmarshalFailsTester) NewEntry() types.EntryImpl { func (u UnmarshalFailsTester) NewEntry() types.EntryImpl {
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
package hashedrekord package hashedrekord
import ( import (
"context"
"errors" "errors"
"testing" "testing"
...@@ -28,46 +27,11 @@ import ( ...@@ -28,46 +27,11 @@ import (
type UnmarshalTester struct { type UnmarshalTester struct {
models.Hashedrekord models.Hashedrekord
} types.BaseUnmarshalTester
func (u UnmarshalTester) NewEntry() types.EntryImpl {
return &UnmarshalTester{}
}
func (u UnmarshalTester) Validate() error {
return nil
}
func (u UnmarshalTester) APIVersion() string {
return "2.0.1"
}
func (u UnmarshalTester) IndexKeys() ([]string, error) {
return []string{}, nil
}
func (u UnmarshalTester) Canonicalize(ctx context.Context) ([]byte, error) {
return nil, nil
}
func (u UnmarshalTester) HasExternalEntities() bool {
return false
}
func (u UnmarshalTester) Unmarshal(pe models.ProposedEntry) error {
return nil
}
func (u UnmarshalTester) Attestation() (string, []byte) {
return "", nil
}
func (u UnmarshalTester) CreateFromArtifactProperties(_ context.Context, _ types.ArtifactProperties) (models.ProposedEntry, error) {
return nil, nil
} }
type UnmarshalFailsTester struct { type UnmarshalFailsTester struct {
UnmarshalTester types.BaseUnmarshalTester
} }
func (u UnmarshalFailsTester) NewEntry() types.EntryImpl { func (u UnmarshalFailsTester) NewEntry() types.EntryImpl {
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
package helm package helm
import ( import (
"context"
"errors" "errors"
"testing" "testing"
...@@ -28,50 +27,11 @@ import ( ...@@ -28,50 +27,11 @@ import (
type UnmarshalTester struct { type UnmarshalTester struct {
models.Helm models.Helm
} types.BaseUnmarshalTester
func (u UnmarshalTester) NewEntry() types.EntryImpl {
return &UnmarshalTester{}
}
func (u UnmarshalTester) Validate() error {
return nil
}
func (u UnmarshalTester) APIVersion() string {
return "2.0.1"
}
func (u UnmarshalTester) IndexKeys() ([]string, error) {
return []string{}, nil
}
func (u UnmarshalTester) Canonicalize(ctx context.Context) ([]byte, error) {
return nil, nil
}
func (u UnmarshalTester) HasExternalEntities() bool {
return false
}
func (u *UnmarshalTester) FetchExternalEntities(ctx context.Context) error {
return nil
}
func (u UnmarshalTester) Unmarshal(pe models.ProposedEntry) error {
return nil
}
func (u UnmarshalTester) Attestation() (string, []byte) {
return "", nil
}
func (u UnmarshalTester) CreateFromArtifactProperties(_ context.Context, _ types.ArtifactProperties) (models.ProposedEntry, error) {
return nil, nil
} }
type UnmarshalFailsTester struct { type UnmarshalFailsTester struct {
UnmarshalTester types.BaseUnmarshalTester
} }
func (u UnmarshalFailsTester) NewEntry() types.EntryImpl { func (u UnmarshalFailsTester) NewEntry() types.EntryImpl {
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
package intoto package intoto
import ( import (
"context"
"errors" "errors"
"testing" "testing"
...@@ -28,50 +27,11 @@ import ( ...@@ -28,50 +27,11 @@ import (
type UnmarshalTester struct { type UnmarshalTester struct {
models.Intoto models.Intoto
} types.BaseUnmarshalTester
func (u UnmarshalTester) NewEntry() types.EntryImpl {
return &UnmarshalTester{}
}
func (u UnmarshalTester) Validate() error {
return nil
}
func (u UnmarshalTester) APIVersion() string {
return "2.0.1"
}
func (u UnmarshalTester) IndexKeys() ([]string, error) {
return []string{}, nil
}
func (u UnmarshalTester) Canonicalize(ctx context.Context) ([]byte, error) {
return nil, nil
}
func (u UnmarshalTester) HasExternalEntities() bool {
return false
}
func (u *UnmarshalTester) FetchExternalEntities(ctx context.Context) error {
return nil
}
func (u UnmarshalTester) Unmarshal(pe models.ProposedEntry) error {
return nil
}
func (u UnmarshalTester) Attestation() (string, []byte) {
return "", nil
}
func (u UnmarshalTester) CreateFromArtifactProperties(_ context.Context, _ types.ArtifactProperties) (models.ProposedEntry, error) {
return nil, nil
} }
type UnmarshalFailsTester struct { type UnmarshalFailsTester struct {
UnmarshalTester types.BaseUnmarshalTester
} }
func (u UnmarshalFailsTester) NewEntry() types.EntryImpl { func (u UnmarshalFailsTester) NewEntry() types.EntryImpl {
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
package jar package jar
import ( import (
"context"
"errors" "errors"
"testing" "testing"
...@@ -27,50 +26,11 @@ import ( ...@@ -27,50 +26,11 @@ import (
type UnmarshalTester struct { type UnmarshalTester struct {
models.Jar models.Jar
} types.BaseUnmarshalTester
func (u UnmarshalTester) NewEntry() types.EntryImpl {
return &UnmarshalTester{}
}
func (u UnmarshalTester) APIVersion() string {
return "2.0.1"
}
func (u UnmarshalTester) IndexKeys() ([]string, error) {
return []string{}, nil
}
func (u UnmarshalTester) Canonicalize(ctx context.Context) ([]byte, error) {
return nil, nil
}
func (u UnmarshalTester) HasExternalEntities() bool {
return false
}
func (u *UnmarshalTester) FetchExternalEntities(ctx context.Context) error {
return nil
}
func (u UnmarshalTester) Unmarshal(pe models.ProposedEntry) error {
return nil
}
func (u UnmarshalTester) Validate() error {
return nil
}
func (u UnmarshalTester) Attestation() (string, []byte) {
return "", nil
}
func (u UnmarshalTester) CreateFromArtifactProperties(_ context.Context, _ types.ArtifactProperties) (models.ProposedEntry, error) {
return nil, nil
} }
type UnmarshalFailsTester struct { type UnmarshalFailsTester struct {
UnmarshalTester types.BaseUnmarshalTester
} }
func (u UnmarshalFailsTester) NewEntry() types.EntryImpl { func (u UnmarshalFailsTester) NewEntry() types.EntryImpl {
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
package rekord package rekord
import ( import (
"context"
"errors" "errors"
"testing" "testing"
...@@ -28,50 +27,11 @@ import ( ...@@ -28,50 +27,11 @@ import (
type UnmarshalTester struct { type UnmarshalTester struct {
models.Rekord models.Rekord
} types.BaseUnmarshalTester
func (u UnmarshalTester) NewEntry() types.EntryImpl {
return &UnmarshalTester{}
}
func (u UnmarshalTester) Validate() error {
return nil
}
func (u UnmarshalTester) APIVersion() string {
return "2.0.1"
}
func (u UnmarshalTester) IndexKeys() ([]string, error) {
return []string{}, nil
}
func (u UnmarshalTester) Canonicalize(ctx context.Context) ([]byte, error) {
return nil, nil
}
func (u UnmarshalTester) HasExternalEntities() bool {
return false
}
func (u *UnmarshalTester) FetchExternalEntities(ctx context.Context) error {
return nil
}
func (u UnmarshalTester) Unmarshal(pe models.ProposedEntry) error {
return nil
}
func (u UnmarshalTester) Attestation() (string, []byte) {
return "", nil
}
func (u UnmarshalTester) CreateFromArtifactProperties(_ context.Context, _ types.ArtifactProperties) (models.ProposedEntry, error) {
return nil, nil
} }
type UnmarshalFailsTester struct { type UnmarshalFailsTester struct {
UnmarshalTester types.BaseUnmarshalTester
} }
func (u UnmarshalFailsTester) NewEntry() types.EntryImpl { func (u UnmarshalFailsTester) NewEntry() types.EntryImpl {
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
package rfc3161 package rfc3161
import ( import (
"context"
"errors" "errors"
"testing" "testing"
...@@ -28,53 +27,11 @@ import ( ...@@ -28,53 +27,11 @@ import (
type UnmarshalTester struct { type UnmarshalTester struct {
models.Rfc3161 models.Rfc3161
} types.BaseUnmarshalTester
func (u UnmarshalTester) NewEntry() types.EntryImpl {
return &UnmarshalTester{}
}
func (u UnmarshalTester) Validate() error {
return nil
}
func (u UnmarshalTester) APIVersion() string {
return "2.0.1"
}
func (u UnmarshalTester) IndexKeys() ([]string, error) {
return []string{}, nil
}
func (u UnmarshalTester) Canonicalize(ctx context.Context) ([]byte, error) {
return nil, nil
}
func (u UnmarshalTester) HasExternalEntities() bool {
return false
}
func (u *UnmarshalTester) FetchExternalEntities(ctx context.Context) error {
return nil
}
func (u UnmarshalTester) Attestation() (string, []byte) {
return "", nil
}
func (u UnmarshalTester) Unmarshal(pe models.ProposedEntry) error {
return nil
}
func (u UnmarshalFailsTester) Attestation() (string, []byte) {
return "", nil
}
func (u UnmarshalTester) CreateFromArtifactProperties(_ context.Context, _ types.ArtifactProperties) (models.ProposedEntry, error) {
return nil, nil
} }
type UnmarshalFailsTester struct { type UnmarshalFailsTester struct {
UnmarshalTester types.BaseUnmarshalTester
} }
func (u UnmarshalFailsTester) NewEntry() types.EntryImpl { func (u UnmarshalFailsTester) NewEntry() types.EntryImpl {
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
package rpm package rpm
import ( import (
"context"
"errors" "errors"
"testing" "testing"
...@@ -28,50 +27,11 @@ import ( ...@@ -28,50 +27,11 @@ import (
type UnmarshalTester struct { type UnmarshalTester struct {
models.Rpm models.Rpm
} types.BaseUnmarshalTester
func (u UnmarshalTester) NewEntry() types.EntryImpl {
return &UnmarshalTester{}
}
func (u UnmarshalTester) APIVersion() string {
return "2.0.1"
}
func (u UnmarshalTester) IndexKeys() ([]string, error) {
return []string{}, nil
}
func (u UnmarshalTester) Canonicalize(ctx context.Context) ([]byte, error) {
return nil, nil
}
func (u UnmarshalTester) HasExternalEntities() bool {
return false
}
func (u *UnmarshalTester) FetchExternalEntities(ctx context.Context) error {
return nil
}
func (u UnmarshalTester) Unmarshal(pe models.ProposedEntry) error {
return nil
}
func (u UnmarshalTester) Validate() error {
return nil
}
func (u UnmarshalTester) Attestation() (string, []byte) {
return "", nil
}
func (u UnmarshalTester) CreateFromArtifactProperties(_ context.Context, _ types.ArtifactProperties) (models.ProposedEntry, error) {
return nil, nil
} }
type UnmarshalFailsTester struct { type UnmarshalFailsTester struct {
UnmarshalTester types.BaseUnmarshalTester
} }
func (u UnmarshalFailsTester) NewEntry() types.EntryImpl { func (u UnmarshalFailsTester) NewEntry() types.EntryImpl {
......
/*
Copyright © 2021 The Sigstore Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package types
import (
"context"
"github.com/sigstore/rekor/pkg/generated/models"
)
type BaseUnmarshalTester struct{}
func (u BaseUnmarshalTester) NewEntry() EntryImpl {
return &BaseUnmarshalTester{}
}
func (u BaseUnmarshalTester) APIVersion() string {
return "2.0.1"
}
func (u BaseUnmarshalTester) IndexKeys() ([]string, error) {
return []string{}, nil
}
func (u BaseUnmarshalTester) Canonicalize(ctx context.Context) ([]byte, error) {
return nil, nil
}
func (u BaseUnmarshalTester) Unmarshal(pe models.ProposedEntry) error {
return nil
}
func (u BaseUnmarshalTester) Validate() error {
return nil
}
func (u BaseUnmarshalTester) Attestation() (string, []byte) {
return "", nil
}
func (u BaseUnmarshalTester) CreateFromArtifactProperties(_ context.Context, _ ArtifactProperties) (models.ProposedEntry, error) {
return nil, nil
}
...@@ -17,7 +17,6 @@ limitations under the License. ...@@ -17,7 +17,6 @@ limitations under the License.
package tuf package tuf
import ( import (
"context"
"errors" "errors"
"testing" "testing"
...@@ -28,46 +27,11 @@ import ( ...@@ -28,46 +27,11 @@ import (
type UnmarshalTester struct { type UnmarshalTester struct {
models.TUF models.TUF
} types.BaseUnmarshalTester
func (u UnmarshalTester) NewEntry() types.EntryImpl {
return &UnmarshalTester{}
}
func (u UnmarshalTester) APIVersion() string {
return "2.0.1"
}
func (u UnmarshalTester) IndexKeys() ([]string, error) {
return []string{}, nil
}
func (u UnmarshalTester) Canonicalize(ctx context.Context) ([]byte, error) {
return nil, nil
}
func (u UnmarshalTester) HasExternalEntities() bool {
return false
}
func (u *UnmarshalTester) FetchExternalEntities(ctx context.Context) error {
return nil
}
func (u UnmarshalTester) Unmarshal(pe models.ProposedEntry) error {
return nil
}
func (u UnmarshalTester) Attestation() (string, []byte) {
return "", nil
}
func (u UnmarshalTester) CreateFromArtifactProperties(_ context.Context, _ types.ArtifactProperties) (models.ProposedEntry, error) {
return nil, nil
} }
type UnmarshalFailsTester struct { type UnmarshalFailsTester struct {
UnmarshalTester types.BaseUnmarshalTester
} }
func (u UnmarshalFailsTester) NewEntry() types.EntryImpl { func (u UnmarshalFailsTester) NewEntry() types.EntryImpl {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment