This repository was archived by the owner on May 8, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
testdata/generate/emptyconfig Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -52,6 +52,18 @@ func TestGenerate(t *testing.T) {
5252 force : true ,
5353 expectedServices : []string {"edward-test-service" },
5454 },
55+ {
56+ name : "existing empty config file" ,
57+ path : "testdata/generate/emptyconfig" ,
58+ config : "edward.json" ,
59+ input : "Y\n " ,
60+ expectedOutput : `The following will be generated:
61+ Services:
62+ edward-test-service
63+ Do you wish to continue? [y/n]? Wrote to: ${TMP_PATH}/edward.json
64+ ` ,
65+ expectedServices : []string {"edward-test-service" },
66+ },
5567 {
5668 name : "duplicates" ,
5769 path : "testdata/generate/duplicatenames" ,
Original file line number Diff line number Diff line change 1+ // A simple executable that stays runnning until an interrupt is received
2+ // Based on: https://gobyexample.com/signals
3+ package main
4+
5+ import (
6+ "fmt"
7+ "log"
8+ "net/http"
9+ "os"
10+ "os/signal"
11+ "time"
12+ )
13+
14+ func handler (w http.ResponseWriter , r * http.Request ) {
15+ fmt .Fprintf (w , "Hello: %s!" , r .URL .Path [1 :])
16+ }
17+
18+ func main () {
19+ http .HandleFunc ("/" , handler )
20+
21+ port := "51936"
22+ fmt .Printf ("Starting to listen on %v\n " , port )
23+ go func () {
24+ log .Fatal (http .ListenAndServe (":" + port , nil ))
25+ }()
26+
27+ timer := time .NewTimer (5 * time .Second )
28+ defer timer .Stop ()
29+
30+ stop := make (chan os.Signal , 1 )
31+ signal .Notify (stop , os .Interrupt )
32+
33+ select {
34+ case <- stop :
35+ fmt .Println ("Terminated" )
36+ case <- timer .C :
37+ fmt .Println ("Timed out" )
38+ }
39+
40+ fmt .Println ("Exiting" )
41+ }
You can’t perform that action at this time.
0 commit comments