package pipeline

import "testing"

func TestParseChunkCacheMode(t *testing.T) {
	for _, value := range []ChunkCacheMode{ChunkCacheAuto, ChunkCacheBypass, ChunkCacheRefresh} {
		got, err := ParseChunkCacheMode(string(value))
		if err != nil || got != value {
			t.Fatalf("ParseChunkCacheMode(%q) = %q, %v", value, got, err)
		}
		if err := value.Validate(); err != nil {
			t.Fatalf("%q.Validate() error = %v", value, err)
		}
	}
	for _, value := range []string{"", "enabled", "AUTO", "auto,refresh"} {
		if _, err := ParseChunkCacheMode(value); err == nil {
			t.Fatalf("ParseChunkCacheMode(%q) error = nil, want error", value)
		}
	}
}
