github.com/diamondburned/arikawa/v2@v2.1.0/api/rate/majors_test.go (about)

     1  package rate
     2  
     3  import "testing"
     4  
     5  func TestBucketKey(t *testing.T) {
     6  	var tests = [][2]string{
     7  		{"/guilds/123123/messages",
     8  			"/guilds/123123/messages"},
     9  		{"/guilds/123123/",
    10  			"/guilds/123123/"},
    11  		{"/channels/123131231",
    12  			"/channels/123131231"},
    13  		{"/channels/123123/message/123456",
    14  			"/channels/123123/message/"},
    15  		{"/user/123123", "/user/"},
    16  		// Not sure about this:
    17  		{"/user/123123/", "/user//"},
    18  		{"/channels/1/messages/1/reactions/🤔/@me",
    19  			"/channels/1/messages//reactions//@me"},
    20  		{"/channels/1/messages/2/reactions/thonk:123123/@me",
    21  			"/channels/1/messages//reactions//@me"},
    22  		// Actual URL:
    23  		{"/channels/486833611564253186/messages/540519319814275089/reactions/🥺/@me",
    24  			"/channels/486833611564253186/messages//reactions//@me"},
    25  	}
    26  
    27  	for _, conds := range tests {
    28  		key := ParseBucketKey(conds[0])
    29  		if key != conds[1] {
    30  			t.Fatalf("Expected/got\n%s\n%s", conds[1], key)
    31  		}
    32  	}
    33  }