Skip to content

Commit

Permalink
Merge pull request #3 from wwsean08/features/unit_tests
Browse files Browse the repository at this point in the history
Features/unit tests
  • Loading branch information
wwsean08 committed Apr 23, 2017
2 parents 8a07544 + 328c5f2 commit 0f4b9d5
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![Build Status](https://travis-ci.org/wwsean08/go-action-sdk.svg?branch=master)](https://travis-ci.org/wwsean08/go-action-sdk) [![Coverage Status](https://coveralls.io/repos/github/wwsean08/go-action-sdk/badge.svg?branch=master)](https://coveralls.io/github/wwsean08/go-action-sdk?branch=master)

## Warning
This is currently an extremely alpha SDK, maybe even pre-alpha, it is not ready for prime time and comes with no guarantees that it will actually work for you. It has worked for my limited test cases, if you do use it and run into issues feel free to open an issue however it's possible I will not maintain this in the long term depending on life and other factors.
This is currently an extremely alpha SDK, maybe even pre-alpha, it is not ready for prime time and comes with no guarantees that it will actually work for you, or that the interfaces won't change (in fact at this moment there are changes planned). It has worked for my limited test cases, if you do use it and run into issues feel free to open an issue however it's possible I will not maintain this in the long term depending on life and other factors.

## About
This is a port of a port. Put simply my javascript experience and knowledge is minimal at best, however [frogermcs](https://github.com/frogermcs/Google-Actions-Java-SDK) ported the action sdk google released from javascript to java. I know java and since I wanted to work in go to make containerization easier and smaller I have ported his work to Go which is my goto language currently.
Expand Down
42 changes: 42 additions & 0 deletions ResponseBuilder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,27 @@ func TestDefaultResponse_AskResponseReturnsExpectedOutput(t *testing.T) {
assert.Nil(t, response.ExpectedInputs[0].InputPrompt_.InitialPrompts[0].SSML)
assert.Equal(t, &message, response.ExpectedInputs[0].InputPrompt_.InitialPrompts[0].TextToSpeech)
assert.Nil(t, response.ExpectedInputs[0].InputPrompt_.NoInputPrompts)

// actual noInputPrompt check
cToken = "42"
message = "This Is A Test"
noInputPromptStr := "Nevermind"
noInputPromptSlice := make([]string, 1)
noInputPromptSlice[0] = noInputPromptStr
response = builder.AskResponse(message, &cToken, noInputPromptSlice)
assert.True(t, response.ExpectUserResponse)
assert.Nil(t, response.FinalResponse_)
assert.NotNil(t, response.ExpectedInputs)
assert.Len(t, response.ExpectedInputs, 1)
assert.Len(t, response.ExpectedInputs[0].PossibleIntents, 1)
assert.Equal(t, "assistant.intent.action.TEXT", response.ExpectedInputs[0].PossibleIntents[0].Intent)
assert.Nil(t, response.ExpectedInputs[0].PossibleIntents[0].InputValueSpec_)
assert.Len(t, response.ExpectedInputs[0].InputPrompt_.InitialPrompts, 1)
assert.Nil(t, response.ExpectedInputs[0].InputPrompt_.InitialPrompts[0].SSML)
assert.Equal(t, &message, response.ExpectedInputs[0].InputPrompt_.InitialPrompts[0].TextToSpeech)
assert.Len(t, response.ExpectedInputs[0].InputPrompt_.NoInputPrompts, 1)
assert.Equal(t, &noInputPromptStr, response.ExpectedInputs[0].InputPrompt_.NoInputPrompts[0].TextToSpeech)
assert.Nil(t, response.ExpectedInputs[0].InputPrompt_.NoInputPrompts[0].SSML)
}

func TestDefaultResponse_AskResponseSSMLReturnsExpectedOutput(t *testing.T) {
Expand All @@ -65,4 +86,25 @@ func TestDefaultResponse_AskResponseSSMLReturnsExpectedOutput(t *testing.T) {
assert.Nil(t, response.ExpectedInputs[0].InputPrompt_.InitialPrompts[0].TextToSpeech)
assert.Equal(t, &message, response.ExpectedInputs[0].InputPrompt_.InitialPrompts[0].SSML)
assert.Nil(t, response.ExpectedInputs[0].InputPrompt_.NoInputPrompts)

// actual noInputPrompt check
cToken = "42"
message = "This Is A Test"
noInputPromptStr := "Nevermind"
noInputPromptSlice := make([]string, 1)
noInputPromptSlice[0] = noInputPromptStr
response = builder.AskResponseSSML(message, &cToken, noInputPromptSlice)
assert.True(t, response.ExpectUserResponse)
assert.Nil(t, response.FinalResponse_)
assert.NotNil(t, response.ExpectedInputs)
assert.Len(t, response.ExpectedInputs, 1)
assert.Len(t, response.ExpectedInputs[0].PossibleIntents, 1)
assert.Equal(t, "assistant.intent.action.TEXT", response.ExpectedInputs[0].PossibleIntents[0].Intent)
assert.Nil(t, response.ExpectedInputs[0].PossibleIntents[0].InputValueSpec_)
assert.Len(t, response.ExpectedInputs[0].InputPrompt_.InitialPrompts, 1)
assert.Nil(t, response.ExpectedInputs[0].InputPrompt_.InitialPrompts[0].TextToSpeech)
assert.Equal(t, &message, response.ExpectedInputs[0].InputPrompt_.InitialPrompts[0].SSML)
assert.Len(t, response.ExpectedInputs[0].InputPrompt_.NoInputPrompts, 1)
assert.Equal(t, &noInputPromptStr, response.ExpectedInputs[0].InputPrompt_.NoInputPrompts[0].SSML)
assert.Nil(t, response.ExpectedInputs[0].InputPrompt_.NoInputPrompts[0].TextToSpeech)
}

0 comments on commit 0f4b9d5

Please sign in to comment.