O'Reilly logo

Isomorphic Go by Kamesh Balasubramanian

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Verifying the contact form's validation functionality

The next test that we are going to implement will test the contact form's server-side form validation functionality. There are two types of validations that we will be testing:

  • An error message that is displayed when the required form field has not been filled
  • An error message that is displayed when an improperly formatted email address value is provided in the email field

Here are the contents of the contactvalidation_test.go source file, found in the tests folder:

package testsimport (  "io/ioutil"  "net/http"  "net/url"  "strconv"  "strings"  "testing")func TestContactFormValidation(t *testing.T) {  testURL := testHost + "/contact" expectedTokenMap := map[string]string{"firstName": "The ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required