-
Notifications
You must be signed in to change notification settings - Fork 740
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #272 from weaveworks/appmesh
Set HTTP listeners for AppMesh virtual routers
- Loading branch information
Showing
6 changed files
with
259 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package notifier | ||
|
||
import ( | ||
"encoding/json" | ||
"io/ioutil" | ||
"net/http" | ||
"net/http/httptest" | ||
"testing" | ||
) | ||
|
||
func Test_postMessage(t *testing.T) { | ||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
b, err := ioutil.ReadAll(r.Body) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
var payload = make(map[string]string) | ||
err = json.Unmarshal(b, &payload) | ||
|
||
if payload["status"] != "success" { | ||
t.Fatal("wrong payload") | ||
} | ||
})) | ||
defer ts.Close() | ||
|
||
err := postMessage(ts.URL, map[string]string{"status": "success"}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package notifier | ||
|
||
import ( | ||
"encoding/json" | ||
"io/ioutil" | ||
"net/http" | ||
"net/http/httptest" | ||
"testing" | ||
) | ||
|
||
func TestSlack_Post(t *testing.T) { | ||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
b, err := ioutil.ReadAll(r.Body) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
var payload = SlackPayload{} | ||
err = json.Unmarshal(b, &payload) | ||
|
||
if payload.Attachments[0].AuthorName != "podinfo.test" { | ||
t.Fatal("wrong author name") | ||
} | ||
})) | ||
defer ts.Close() | ||
|
||
slack, err := NewSlack(ts.URL, "test", "test") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
err = slack.Post("podinfo", "test", "test", nil, true) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package notifier | ||
|
||
import ( | ||
"encoding/json" | ||
"io/ioutil" | ||
"net/http" | ||
"net/http/httptest" | ||
"testing" | ||
) | ||
|
||
func TestTeams_Post(t *testing.T) { | ||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
b, err := ioutil.ReadAll(r.Body) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
var payload = MSTeamsPayload{} | ||
err = json.Unmarshal(b, &payload) | ||
|
||
if payload.Sections[0].ActivitySubtitle != "podinfo.test" { | ||
t.Fatal("wrong activity subtitle") | ||
} | ||
})) | ||
defer ts.Close() | ||
|
||
teams, err := NewMSTeams(ts.URL) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
err = teams.Post("podinfo", "test", "test", nil, true) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters