github.com/criteo/command-launcher@v0.0.0-20230407142452-fb616f546e98/internal/updater/cmd-updater_test.go (about)

     1  package updater
     2  
     3  import (
     4  	"os"
     5  	"path/filepath"
     6  	"testing"
     7  
     8  	"github.com/stretchr/testify/assert"
     9  )
    10  
    11  func TestLoadLockedPackages(t *testing.T) {
    12  	file, _ := os.Open("assets/lock.json")
    13  	assert.NotNil(t, file)
    14  
    15  	cmdUpdater := CmdUpdater{}
    16  
    17  	fullPath, _ := filepath.Abs("assets/lock.json")
    18  	lockedPkgs, err := cmdUpdater.LoadLockedPackages(fullPath)
    19  	assert.Nil(t, err)
    20  	assert.Equal(t, 2, len(lockedPkgs))
    21  	assert.Equal(t, "1.0.0", lockedPkgs["hello"])
    22  	assert.Equal(t, "0.0.1", lockedPkgs["another-pkg"])
    23  }