github.com/quay/claircore@v1.5.28/indexer/controller/coalesce_test.go (about)

     1  package controller
     2  
     3  import (
     4  	"context"
     5  	"testing"
     6  
     7  	"github.com/quay/zlog"
     8  
     9  	"github.com/quay/claircore/indexer"
    10  )
    11  
    12  // TestCoalesce confirms when no error is encountered
    13  // the coalesce method will transition to the correct
    14  // state.
    15  //
    16  // This test simply provides no Ecosystems to the index
    17  // controller and does no work.
    18  func TestCoalesce(t *testing.T) {
    19  	ctx := context.Background()
    20  	var tt = []struct {
    21  		name          string
    22  		expectedState State
    23  	}{
    24  		{
    25  			name:          "Success",
    26  			expectedState: IndexManifest,
    27  		},
    28  	}
    29  
    30  	for _, table := range tt {
    31  		t.Run(table.name, func(t *testing.T) {
    32  			ctx := zlog.Test(ctx, t)
    33  			indexer := New(&indexer.Options{})
    34  
    35  			state, err := coalesce(ctx, indexer)
    36  			if err != nil {
    37  				t.Fatalf("did not expect error: %v", err)
    38  			}
    39  			if table.expectedState != state {
    40  				t.Fatalf("got: %s, wanted: %s", table.expectedState, state)
    41  			}
    42  		})
    43  	}
    44  }