• refcell.eth's avatar
    feat(ops): Consolidate Version Control (#8920) · 23dd85a4
    refcell.eth authored
    * feat(ops): consolidate version control
    
    * fix: remove added slitherrc copy
    
    * fix: Makefile geth install target
    
    * fix: remove other redundant cat commands
    
    * fix: rabbit's suggestion
    23dd85a4
utils_test.go 953 Bytes
package bindgen

import (
	"encoding/json"
	"os"
	"path"
	"testing"

	"github.com/stretchr/testify/require"
)

func TestReadExpectedAbigenVersion(t *testing.T) {
	// Create a temporary directory for the version control file.
	tmpDir := path.Join(os.TempDir(), "version-tests")
	defer os.RemoveAll(tmpDir)
	require.NoError(t, os.MkdirAll(tmpDir, 0755))

	// Create a temporary version control file.
	versionFile := path.Join(tmpDir, "versions.json")
	versions := Versions{Abigen: "v1.2.3"}

	// Marshal the versions to JSON.
	versionsJSON, err := json.Marshal(versions)
	require.NoError(t, err)

	// Write the JSON to the version control file.
	require.NoError(t, os.WriteFile(versionFile, versionsJSON, 0644))

	// Read the expected version from the version control file.
	// The read version should not have a "v" prefix.
	expectedVersion, err := readExpectedAbigenVersion(tmpDir)
	require.NoError(t, err)
	require.Equal(t, expectedVersion, "1.2.3")
}