github.com/smugmug/godynamo@v0.0.0-20151122084750-7913028f6623/tests/delete_table-livetest.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"github.com/smugmug/godynamo/conf"
     6  	"github.com/smugmug/godynamo/conf_file"
     7  	conf_iam "github.com/smugmug/godynamo/conf_iam"
     8  	delete_table "github.com/smugmug/godynamo/endpoints/delete_table"
     9  	list "github.com/smugmug/godynamo/endpoints/list_tables"
    10  	keepalive "github.com/smugmug/godynamo/keepalive"
    11  	"log"
    12  	"net/http"
    13  	"os"
    14  )
    15  
    16  func main() {
    17  	conf_file.Read()
    18  	conf.Vals.ConfLock.RLock()
    19  	if conf.Vals.Initialized == false {
    20  		panic("the conf.Vals global conf struct has not been initialized")
    21  	}
    22  
    23  	// launch a background poller to keep conns to aws alive
    24  	if conf.Vals.Network.DynamoDB.KeepAlive {
    25  		log.Printf("launching background keepalive")
    26  		go keepalive.KeepAlive([]string{})
    27  	}
    28  
    29  	// deal with iam, or not
    30  	if conf.Vals.UseIAM {
    31  		iam_ready_chan := make(chan bool)
    32  		go conf_iam.GoIAM(iam_ready_chan)
    33  		_ = <-iam_ready_chan
    34  	}
    35  	conf.Vals.ConfLock.RUnlock()
    36  
    37  	tn := "test-godynamo-livetest"
    38  	tablename1 := tn
    39  	fmt.Printf("tablename1: %s\n", tablename1)
    40  
    41  	var code int
    42  	var err error
    43  	var body []byte
    44  
    45  	// DELETE THE TABLE
    46  	del_table1 := delete_table.NewDeleteTable()
    47  	del_table1.TableName = tablename1
    48  	body, code, err = del_table1.EndpointReq()
    49  	if err != nil || code != http.StatusOK {
    50  		fmt.Printf("fail delete %d %v %s\n", code, err, string(body))
    51  		os.Exit(1)
    52  	}
    53  	fmt.Printf("%v\n%v\n,%v\n", string(body), code, err)
    54  
    55  	// List TABLES
    56  	var l list.List
    57  	l.ExclusiveStartTableName = ""
    58  	l.Limit = 100
    59  	body, code, err = l.EndpointReq()
    60  	if err != nil || code != http.StatusOK {
    61  		fmt.Printf("fail delete %d %v %s\n", code, err, string(body))
    62  		os.Exit(1)
    63  	}
    64  	fmt.Printf("%v\n%v\n,%v\n", string(body), code, err)
    65  }