func TestIPNotINSubnet(t *testing.T) {
	conf := `{
			"name": "testnet",
			"cniVersion": "0.3.0",
			"ipam": {
				"type": "ipam",
				"ipv4-gateway": "10.0.0.1",
				"ipv4-subnet": '10.0.0.0/24'
				"ipv4-address": "10.0.1.2/24"
			}
		}`
	_, _, err := LoadIPAMConfig([]byte(conf), "")
	assert.Error(t, err, "Specified IP not in the subnet should cause error")
}
TestIPNotINSubnet tests if the specified ip is not in the subnet
package config
import (
	"fmt"
	"net"
	"os"
	"testing"
	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
)
func TestDefaultDBPath(t *testing.T) {
	os.Unsetenv(EnvDBPath)
	conf, err := LoadDBConfig()
	assert.NoError(t, err, "loading db config failed")
	assert.Equal(t, DefaultDBPath, conf.DB, "the default DB path will be used if not set by IPAM_DB_PATH")
}
func TestDBPathFromEnv(t *testing.T) {
	os.Setenv(EnvDBPath, "/tmp/test")
	defer os.Unsetenv(EnvDBPath)
	conf, err := LoadDBConfig()
	assert.NoError(t, err, "loading db config failed")
	assert.Equal(t, conf.DB, "/tmp/test")
}
func TestInvalidIPV4Address(t *testing.T) {
	conf := `{
			"name": "testnet",
			"cniVersion": "0.3.0",
			"ipam": {
				"type": "ipam",
				"ipv4-subnet": "10.0.0.0/24",
				"ipv4-address": "%s"
			}
		}`
	_, _, err := LoadIPAMConfig([]byte(fmt.Sprintf(conf, "10.0.0")), "")
	assert.Error(t, err, "expect error for invalid ip address")
	_, _, err = LoadIPAMConfig([]byte(fmt.Sprintf(conf, "10.0.0.1")), "")
	assert.Error(t, err, "expect error for missing mask in ipv4-address")
	_, _, err = LoadIPAMConfig([]byte(fmt.Sprintf(conf, "10.0.0.2/24")), "")
	assert.NoError(t, err, "valid ip address should not cause loading configuration error")
	_, _, err = LoadIPAMConfig([]byte(fmt.Sprintf(conf, "")), "")
	assert.Error(t, err, "expect error for missing IP address in the configuration")
}