func TestGetExistedIP(t *testing.T) {
	defer cleanup(t)
	conf := `{
			"name": "testnet",
			"cniVersion": "0.3.0",
			"ipam": {
				"type": "ipam",
				"ipv4-address": "10.0.0.2/24",
				"timeout": "5s",
				"ipv4-subnet": "10.0.0.0/24",
				"ipv4-gateway": "10.0.0.8",
				"ipv4-routes": [
				{"dst": "192.168.2.3/32"}
				]
			}
		}`
	args := &skel.CmdArgs{
		StdinData: []byte(conf),
	}
	err := commands.Add(args)
	assert.NoError(t, err, "expect no error")
	err = commands.Add(args)
	assert.Error(t, err, "expect error for requiring used IP")
}
TestGetExistedIP tests get an used IP from the ipv4-subnet will cause error
package main
import (
	"io/ioutil"
	"net"
	"os"
	"testing"
	"github.com/aws/amazon-ecs-cni-plugins/plugins/ipam/commands"
	"github.com/aws/amazon-ecs-cni-plugins/plugins/ipam/config"
	"github.com/containernetworking/cni/pkg/skel"
	"github.com/containernetworking/cni/pkg/types/current"
	"github.com/containernetworking/cni/pkg/version"
	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
)
const (
	testdb = "/tmp/ipam_test"
)
func init() {
	os.Setenv(config.EnvDBPath, testdb)
}
func cleanup(t *testing.T) {
	_, err := os.Stat(testdb)
	if err != nil {
		require.True(t, os.IsNotExist(err), "if it's not file not exist error, then there should be a problem: %v", err)
	} else {
		err = os.Remove(testdb)
		require.NoError(t, err, "Remove the existed db should not cause error")
	}
}