github.com/15mga/kiwi@v0.0.2-0.20240324021231-b95d5c3ac751/util/etd/etcd_test.go (about)

     1  package etd
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  	"time"
     7  
     8  	"github.com/stretchr/testify/assert"
     9  	etcd "go.etcd.io/etcd/client/v3"
    10  )
    11  
    12  func TestLease(t *testing.T) {
    13  	err := Conn(etcd.Config{
    14  		Endpoints: []string{"127.0.0.1:2379"},
    15  	})
    16  	assert.Nil(t, err)
    17  	id, err := PutWithTtl("test", "95eh", 10)
    18  	assert.Nil(t, err)
    19  	time.Sleep(time.Second * 7)
    20  	fmt.Println("revoke")
    21  	_ = Revoke(id)
    22  	time.Sleep(time.Second * 5)
    23  }