|
| 1 | +// Copyright 2015 The Cockroach Authors. |
| 2 | +// |
| 3 | +// Use of this software is governed by the Business Source License |
| 4 | +// included in the file licenses/BSL.txt. |
| 5 | +// |
| 6 | +// As of the Change Date specified in that file, in accordance with |
| 7 | +// the Business Source License, use of this software will be governed |
| 8 | +// by the Apache License, Version 2.0, included in the file |
| 9 | +// licenses/APL.txt. |
| 10 | + |
| 11 | +package tree_test |
| 12 | + |
| 13 | +import ( |
| 14 | + "testing" |
| 15 | + |
| 16 | + "github.com/cockroachdb/cockroach/pkg/kv/kvserver/concurrency/isolation" |
| 17 | + "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" |
| 18 | + "github.com/cockroachdb/cockroach/pkg/util/leaktest" |
| 19 | + "github.com/stretchr/testify/require" |
| 20 | +) |
| 21 | + |
| 22 | +func TestIsolationLevelFromKVTxnIsolationLevel(t *testing.T) { |
| 23 | + defer leaktest.AfterTest(t)() |
| 24 | + |
| 25 | + testCases := []struct { |
| 26 | + In isolation.Level |
| 27 | + Out tree.IsolationLevel |
| 28 | + }{ |
| 29 | + { |
| 30 | + In: isolation.Serializable, |
| 31 | + Out: tree.SerializableIsolation, |
| 32 | + }, |
| 33 | + { |
| 34 | + In: isolation.ReadCommitted, |
| 35 | + Out: tree.ReadCommittedIsolation, |
| 36 | + }, |
| 37 | + { |
| 38 | + In: isolation.Snapshot, |
| 39 | + Out: tree.SnapshotIsolation, |
| 40 | + }, |
| 41 | + } |
| 42 | + |
| 43 | + for _, tc := range testCases { |
| 44 | + require.Equal(t, tc.Out, tree.IsolationLevelFromKVTxnIsolationLevel(tc.In)) |
| 45 | + } |
| 46 | +} |
0 commit comments