github.com/myhau/pulumi/pkg/v3@v3.70.2-0.20221116134521-f2775972e587/resource/stack/checkpoint_test.go (about) 1 // Copyright 2016-2018, Pulumi Corporation. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package stack 16 17 import ( 18 "io/ioutil" 19 "testing" 20 21 "github.com/pulumi/pulumi/sdk/v3/go/common/encoding" 22 "github.com/stretchr/testify/assert" 23 ) 24 25 func TestLoadV0Checkpoint(t *testing.T) { 26 t.Parallel() 27 28 bytes, err := ioutil.ReadFile("testdata/checkpoint-v0.json") 29 assert.NoError(t, err) 30 31 chk, err := UnmarshalVersionedCheckpointToLatestCheckpoint(encoding.JSON, bytes) 32 assert.NoError(t, err) 33 assert.NotNil(t, chk.Latest) 34 assert.Len(t, chk.Latest.Resources, 30) 35 } 36 37 func TestLoadV1Checkpoint(t *testing.T) { 38 t.Parallel() 39 40 bytes, err := ioutil.ReadFile("testdata/checkpoint-v1.json") 41 assert.NoError(t, err) 42 43 chk, err := UnmarshalVersionedCheckpointToLatestCheckpoint(encoding.JSON, bytes) 44 assert.NoError(t, err) 45 assert.NotNil(t, chk.Latest) 46 assert.Len(t, chk.Latest.Resources, 30) 47 } 48 49 func TestLoadV3Checkpoint(t *testing.T) { 50 t.Parallel() 51 52 bytes, err := ioutil.ReadFile("testdata/checkpoint-v3.json") 53 assert.NoError(t, err) 54 55 chk, err := UnmarshalVersionedCheckpointToLatestCheckpoint(encoding.JSON, bytes) 56 assert.NoError(t, err) 57 assert.NotNil(t, chk.Latest) 58 assert.Len(t, chk.Latest.Resources, 30) 59 }