github.com/Psiphon-Labs/goarista@v0.0.0-20160825065156-d002785f4c67/elasticsearch/mappings_test.go (about)

     1  // Copyright (C) 2016  Arista Networks, Inc.
     2  // Use of this source code is governed by the Apache License 2.0
     3  // that can be found in the COPYING file.
     4  
     5  package elasticsearch
     6  
     7  import (
     8  	"testing"
     9  )
    10  
    11  func TestEscapeFieldName(t *testing.T) {
    12  	testcases := []struct {
    13  		unescaped string
    14  		escaped   string
    15  	}{{
    16  		unescaped: "239.255.255.250_32_0.0.0.0_0",
    17  		escaped:   "239_255_255_250_32_0_0_0_0_0",
    18  	}, {
    19  		unescaped: "foo",
    20  		escaped:   "foo",
    21  	},
    22  	}
    23  	for _, test := range testcases {
    24  		escaped := EscapeFieldName(test.unescaped)
    25  		if escaped != test.escaped {
    26  			t.Errorf("Failed to escape %q: expected %q, got %q", test.unescaped,
    27  				test.escaped, escaped)
    28  		}
    29  	}
    30  }