initial commits
parent
c22e57f699
commit
a22d4dbcf3
|
@ -0,0 +1,21 @@
|
|||
package frameproto
|
||||
|
||||
// AppendFrameButton1Target will append the HTML <meta/> element for the Frame-Protocol's (i.e., Farcaster Frame's) "fc:frame:button:1:target" name-value pair.
|
||||
//
|
||||
// For example, this call:
|
||||
//
|
||||
// var p []byte
|
||||
//
|
||||
// // ...
|
||||
//
|
||||
// var target string = "https://example.com/thing/do-it"
|
||||
//
|
||||
// p = frameproto.AppendFrameButton1Target(p, target)
|
||||
//
|
||||
// Would append this HTML <meta/> element:
|
||||
//
|
||||
// <meta property="fc:frame:button:1:target" content="https://example.com/thing/do-it" />
|
||||
func AppendFrameButton1Target(p []byte, target string) []byte {
|
||||
const property string = MetaPropertyFrameButton1Target
|
||||
return appendMetaPropertyContent(p, property, target)
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
package frameproto
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAppendFrameButton1Target(t *testing.T) {
|
||||
|
||||
tests := []struct{
|
||||
Target string
|
||||
Expected string
|
||||
}{
|
||||
{
|
||||
Target: "",
|
||||
Expected: `<meta property="fc:frame:button:1:target" content="" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Target: "something",
|
||||
Expected: `<meta property="fc:frame:button:1:target" content="something" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Target: "Hello world! 🙂",
|
||||
Expected: `<meta property="fc:frame:button:1:target" content="Hello world! 🙂" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Target: "https://example.com/path/to/post/to.php",
|
||||
Expected: `<meta property="fc:frame:button:1:target" content="https://example.com/path/to/post/to.php" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Target: "x-proto:apple/banana/cherry",
|
||||
Expected: `<meta property="fc:frame:button:1:target" content="x-proto:apple/banana/cherry" />`+"\n",
|
||||
},
|
||||
}
|
||||
|
||||
for testNumber, test := range tests {
|
||||
|
||||
{
|
||||
var buffer [256]byte
|
||||
var p []byte = buffer[0:0]
|
||||
|
||||
p = AppendFrameButton1Target(p, test.Target)
|
||||
|
||||
expected := test.Expected
|
||||
actual := string(p)
|
||||
|
||||
if expected != actual {
|
||||
t.Errorf("For test #%d, the actual written meta-tag is not what was expected." ,testNumber)
|
||||
t.Logf("EXPECTED: %s", expected)
|
||||
t.Logf("ACTUAL: %s", actual)
|
||||
t.Logf("EXPECTED: %q", expected)
|
||||
t.Logf("ACTUAL: %q", actual)
|
||||
t.Logf("Target: %q", test.Target)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const top string = "<html>\n<head>\n"
|
||||
const bottom string = "</head>\n<body>\n</body>\n</html>\n"
|
||||
|
||||
var buffer [256]byte
|
||||
var p []byte = buffer[0:0]
|
||||
|
||||
p = append(p, top...)
|
||||
|
||||
p = AppendFrameButton1Target(p, test.Target)
|
||||
|
||||
p = append(p, bottom...)
|
||||
|
||||
expected := top + test.Expected + bottom
|
||||
actual := string(p)
|
||||
|
||||
if expected != actual {
|
||||
t.Errorf("For test #%d, the actual written meta-tag is not what was expected." ,testNumber)
|
||||
t.Logf("EXPECTED: %s", expected)
|
||||
t.Logf("ACTUAL: %s", actual)
|
||||
t.Logf("EXPECTED: %q", expected)
|
||||
t.Logf("ACTUAL: %q", actual)
|
||||
t.Logf("Target: %q", test.Target)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package frameproto
|
||||
|
||||
// AppendFrameButton2Target will append the HTML <meta/> element for the Frame-Protocol's (i.e., Farcaster Frame's) "fc:frame:button:2:target" name-value pair.
|
||||
//
|
||||
// For example, this call:
|
||||
//
|
||||
// var p []byte
|
||||
//
|
||||
// // ...
|
||||
//
|
||||
// var target string = "https://example.com/thing/do-it"
|
||||
//
|
||||
// p = frameproto.AppendFrameButton2Target(p, target)
|
||||
//
|
||||
// Would append this HTML <meta/> element:
|
||||
//
|
||||
// <meta property="fc:frame:button:2:target" content="https://example.com/thing/do-it" />
|
||||
func AppendFrameButton2Target(p []byte, target string) []byte {
|
||||
const property string = MetaPropertyFrameButton2Target
|
||||
return appendMetaPropertyContent(p, property, target)
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
package frameproto
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAppendFrameButton2Target(t *testing.T) {
|
||||
|
||||
tests := []struct{
|
||||
Target string
|
||||
Expected string
|
||||
}{
|
||||
{
|
||||
Target: "",
|
||||
Expected: `<meta property="fc:frame:button:2:target" content="" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Target: "something",
|
||||
Expected: `<meta property="fc:frame:button:2:target" content="something" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Target: "Hello world! 🙂",
|
||||
Expected: `<meta property="fc:frame:button:2:target" content="Hello world! 🙂" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Target: "https://example.com/path/to/post/to.php",
|
||||
Expected: `<meta property="fc:frame:button:2:target" content="https://example.com/path/to/post/to.php" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Target: "x-proto:apple/banana/cherry",
|
||||
Expected: `<meta property="fc:frame:button:2:target" content="x-proto:apple/banana/cherry" />`+"\n",
|
||||
},
|
||||
}
|
||||
|
||||
for testNumber, test := range tests {
|
||||
|
||||
{
|
||||
var buffer [256]byte
|
||||
var p []byte = buffer[0:0]
|
||||
|
||||
p = AppendFrameButton2Target(p, test.Target)
|
||||
|
||||
expected := test.Expected
|
||||
actual := string(p)
|
||||
|
||||
if expected != actual {
|
||||
t.Errorf("For test #%d, the actual written meta-tag is not what was expected." ,testNumber)
|
||||
t.Logf("EXPECTED: %s", expected)
|
||||
t.Logf("ACTUAL: %s", actual)
|
||||
t.Logf("EXPECTED: %q", expected)
|
||||
t.Logf("ACTUAL: %q", actual)
|
||||
t.Logf("Target: %q", test.Target)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const top string = "<html>\n<head>\n"
|
||||
const bottom string = "</head>\n<body>\n</body>\n</html>\n"
|
||||
|
||||
var buffer [256]byte
|
||||
var p []byte = buffer[0:0]
|
||||
|
||||
p = append(p, top...)
|
||||
|
||||
p = AppendFrameButton2Target(p, test.Target)
|
||||
|
||||
p = append(p, bottom...)
|
||||
|
||||
expected := top + test.Expected + bottom
|
||||
actual := string(p)
|
||||
|
||||
if expected != actual {
|
||||
t.Errorf("For test #%d, the actual written meta-tag is not what was expected." ,testNumber)
|
||||
t.Logf("EXPECTED: %s", expected)
|
||||
t.Logf("ACTUAL: %s", actual)
|
||||
t.Logf("EXPECTED: %q", expected)
|
||||
t.Logf("ACTUAL: %q", actual)
|
||||
t.Logf("Target: %q", test.Target)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package frameproto
|
||||
|
||||
// AppendFrameButton3Target will append the HTML <meta/> element for the Frame-Protocol's (i.e., Farcaster Frame's) "fc:frame:button:3:target" name-value pair.
|
||||
//
|
||||
// For example, this call:
|
||||
//
|
||||
// var p []byte
|
||||
//
|
||||
// // ...
|
||||
//
|
||||
// var target string = "https://example.com/thing/do-it"
|
||||
//
|
||||
// p = frameproto.AppendFrameButton3Target(p, target)
|
||||
//
|
||||
// Would append this HTML <meta/> element:
|
||||
//
|
||||
// <meta property="fc:frame:button:3:target" content="https://example.com/thing/do-it" />
|
||||
func AppendFrameButton3Target(p []byte, target string) []byte {
|
||||
const property string = MetaPropertyFrameButton3Target
|
||||
return appendMetaPropertyContent(p, property, target)
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
package frameproto
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAppendFrameButton3Target(t *testing.T) {
|
||||
|
||||
tests := []struct{
|
||||
Target string
|
||||
Expected string
|
||||
}{
|
||||
{
|
||||
Target: "",
|
||||
Expected: `<meta property="fc:frame:button:3:target" content="" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Target: "something",
|
||||
Expected: `<meta property="fc:frame:button:3:target" content="something" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Target: "Hello world! 🙂",
|
||||
Expected: `<meta property="fc:frame:button:3:target" content="Hello world! 🙂" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Target: "https://example.com/path/to/post/to.php",
|
||||
Expected: `<meta property="fc:frame:button:3:target" content="https://example.com/path/to/post/to.php" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Target: "x-proto:apple/banana/cherry",
|
||||
Expected: `<meta property="fc:frame:button:3:target" content="x-proto:apple/banana/cherry" />`+"\n",
|
||||
},
|
||||
}
|
||||
|
||||
for testNumber, test := range tests {
|
||||
|
||||
{
|
||||
var buffer [256]byte
|
||||
var p []byte = buffer[0:0]
|
||||
|
||||
p = AppendFrameButton3Target(p, test.Target)
|
||||
|
||||
expected := test.Expected
|
||||
actual := string(p)
|
||||
|
||||
if expected != actual {
|
||||
t.Errorf("For test #%d, the actual written meta-tag is not what was expected." ,testNumber)
|
||||
t.Logf("EXPECTED: %s", expected)
|
||||
t.Logf("ACTUAL: %s", actual)
|
||||
t.Logf("EXPECTED: %q", expected)
|
||||
t.Logf("ACTUAL: %q", actual)
|
||||
t.Logf("Target: %q", test.Target)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const top string = "<html>\n<head>\n"
|
||||
const bottom string = "</head>\n<body>\n</body>\n</html>\n"
|
||||
|
||||
var buffer [256]byte
|
||||
var p []byte = buffer[0:0]
|
||||
|
||||
p = append(p, top...)
|
||||
|
||||
p = AppendFrameButton3Target(p, test.Target)
|
||||
|
||||
p = append(p, bottom...)
|
||||
|
||||
expected := top + test.Expected + bottom
|
||||
actual := string(p)
|
||||
|
||||
if expected != actual {
|
||||
t.Errorf("For test #%d, the actual written meta-tag is not what was expected." ,testNumber)
|
||||
t.Logf("EXPECTED: %s", expected)
|
||||
t.Logf("ACTUAL: %s", actual)
|
||||
t.Logf("EXPECTED: %q", expected)
|
||||
t.Logf("ACTUAL: %q", actual)
|
||||
t.Logf("Target: %q", test.Target)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package frameproto
|
||||
|
||||
// AppendFrameButton4Target will append the HTML <meta/> element for the Frame-Protocol's (i.e., Farcaster Frame's) "fc:frame:button:4:target" name-value pair.
|
||||
//
|
||||
// For example, this call:
|
||||
//
|
||||
// var p []byte
|
||||
//
|
||||
// // ...
|
||||
//
|
||||
// var target string = "https://example.com/thing/do-it"
|
||||
//
|
||||
// p = frameproto.AppendFrameButton4Target(p, target)
|
||||
//
|
||||
// Would append this HTML <meta/> element:
|
||||
//
|
||||
// <meta property="fc:frame:button:4:target" content="https://example.com/thing/do-it" />
|
||||
func AppendFrameButton4Target(p []byte, target string) []byte {
|
||||
const property string = MetaPropertyFrameButton4Target
|
||||
return appendMetaPropertyContent(p, property, target)
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
package frameproto
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAppendFrameButton4Target(t *testing.T) {
|
||||
|
||||
tests := []struct{
|
||||
Target string
|
||||
Expected string
|
||||
}{
|
||||
{
|
||||
Target: "",
|
||||
Expected: `<meta property="fc:frame:button:4:target" content="" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Target: "something",
|
||||
Expected: `<meta property="fc:frame:button:4:target" content="something" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Target: "Hello world! 🙂",
|
||||
Expected: `<meta property="fc:frame:button:4:target" content="Hello world! 🙂" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Target: "https://example.com/path/to/post/to.php",
|
||||
Expected: `<meta property="fc:frame:button:4:target" content="https://example.com/path/to/post/to.php" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Target: "x-proto:apple/banana/cherry",
|
||||
Expected: `<meta property="fc:frame:button:4:target" content="x-proto:apple/banana/cherry" />`+"\n",
|
||||
},
|
||||
}
|
||||
|
||||
for testNumber, test := range tests {
|
||||
|
||||
{
|
||||
var buffer [256]byte
|
||||
var p []byte = buffer[0:0]
|
||||
|
||||
p = AppendFrameButton4Target(p, test.Target)
|
||||
|
||||
expected := test.Expected
|
||||
actual := string(p)
|
||||
|
||||
if expected != actual {
|
||||
t.Errorf("For test #%d, the actual written meta-tag is not what was expected." ,testNumber)
|
||||
t.Logf("EXPECTED: %s", expected)
|
||||
t.Logf("ACTUAL: %s", actual)
|
||||
t.Logf("EXPECTED: %q", expected)
|
||||
t.Logf("ACTUAL: %q", actual)
|
||||
t.Logf("Target: %q", test.Target)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const top string = "<html>\n<head>\n"
|
||||
const bottom string = "</head>\n<body>\n</body>\n</html>\n"
|
||||
|
||||
var buffer [256]byte
|
||||
var p []byte = buffer[0:0]
|
||||
|
||||
p = append(p, top...)
|
||||
|
||||
p = AppendFrameButton4Target(p, test.Target)
|
||||
|
||||
p = append(p, bottom...)
|
||||
|
||||
expected := top + test.Expected + bottom
|
||||
actual := string(p)
|
||||
|
||||
if expected != actual {
|
||||
t.Errorf("For test #%d, the actual written meta-tag is not what was expected." ,testNumber)
|
||||
t.Logf("EXPECTED: %s", expected)
|
||||
t.Logf("ACTUAL: %s", actual)
|
||||
t.Logf("EXPECTED: %q", expected)
|
||||
t.Logf("ACTUAL: %q", actual)
|
||||
t.Logf("Target: %q", test.Target)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue