github.com/iron-io/functions@v0.0.0-20180820112432-d59d7d1c40b2/examples/postgres/test.sh (about)

     1  #!/bin/bash
     2  set -x
     3  
     4  docker stop test-postgres-func
     5  docker rm test-postgres-func
     6  
     7  docker run -p 5432:5432 --name test-postgres-func -d postgres
     8  sleep 5s
     9  
    10  docker run --rm -i --link test-postgres-func:postgres postgres psql -h postgres -U postgres -c 'CREATE TABLE people (first TEXT, last TEXT, age INTEGER);'
    11  
    12  RECORD1='{
    13      "first": "John",
    14      "last": "Smith",
    15      "age": 30
    16  }'
    17  echo $RECORD1 | fn run -e SERVER=postgres:5432 -e COMMAND=INSERT -e TABLE=people --link test-postgres-func:postgres
    18  QUERY1='{
    19      "last": "Smith"
    20  }'
    21  echo $QUERY1 | fn run -e SERVER=postgres:5432 -e COMMAND=SELECT -e TABLE=people --link test-postgres-func:postgres
    22  
    23  RECORD2='{
    24      "first": "Bob",
    25      "last": "Smith",
    26      "age": 43
    27  }'
    28  echo $RECORD2 | fn run -e SERVER=postgres:5432 -e COMMAND=INSERT -e TABLE=people --link test-postgres-func:postgres
    29  
    30  echo $QUERY1 | fn run -e SERVER=postgres:5432 -e COMMAND=SELECT -e TABLE=people --link test-postgres-func:postgres
    31  
    32  QUERY2='{
    33      "first": "John",
    34      "last": "Smith"
    35  }'
    36  echo $QUERY2 | fn run -e SERVER=postgres:5432 -e COMMAND=SELECT -e TABLE=people --link test-postgres-func:postgres
    37  
    38  docker stop test-postgres-func
    39  docker rm test-postgres-func