Created
          August 31, 2016 18:05 
        
      - 
      
- 
        Save dougluce/6d02011cb452e491f6526a1fb8a38f3e to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package main | |
| import ( | |
| "encoding/base64" | |
| "fmt" | |
| yaml "gopkg.in/yaml.v2" | |
| "regexp" | |
| ) | |
| var fixtureFiles = ` | |
| digger_static_06-09-16-11:18:48: | | |
| josephmaltz 30 | |
| josephmaltz 20 | |
| robjerfy 50 | |
| josephmaltz 10 | |
| digger_static_06-09-16-11:19:59: | | |
| robjerfy 3 | |
| josephmaltz 2 | |
| robjerfy 5 | |
| josephmaltz 1 | |
| plan_static_06-09-16-11:18:48: | | |
| 5723f6e1b149030b3ec24800 30 | |
| 5723f6e1b149030b3ec24801 10 | |
| plan_static_06-09-16-11:19:59: | | |
| 5723f6e1b149030b3ec24801 80 | |
| device_data_static_06-09-16-11:18:48: | | |
| b64{{["5723f6e1b149030b3ec24800","josephmaltz","2016-06-07 00:00:00",17,"2","Robot",5,"2000"]}} w 0.030001 | |
| b64{{["5723f6e1b149030b3ec24800","josephmaltz","2016-06-07 00:00:00",17,"2","Robot",5,"2000"]}} w 0.030002 | |
| b64{{["5723f6e1b149030b3ec24800","josephmaltz","2016-06-07 00:00:00",17,"2","Robot",5,"2000"]}} w 0.030003 | |
| location_data_static_06-09-16-11:18:48: | | |
| b64{{["5723f6e1b149030b3ec24800","josephmaltz","2016-06-07 00:00:00",17,"atlanta","il","us"]}} w 0.030004 | |
| b64{{["5723f6e1b149030b3ec24800","josephmaltz","2016-06-07 00:00:00",17,"atlanta","il","us"]}} w 0.030005 | |
| b64{{["5723f6e1b149030b3ec24800","josephmaltz","2016-06-07 00:00:00",17,"atlanta","il","us"]}} w 0.030006 | |
| b64{{["5723f6e1b1490f0b3ec24800","josephmaltz","2016-06-07 00:00:00",17,"batlanta","ilb","ubs"]}} w 0.030007 | |
| b64{{["5723f6e1b1490f0b3ec24800","josephmaltz","2016-06-07 00:00:00",17,"batlanta","ilb","ubs"]}} w 0.030008 | |
| b64{{["5723f6e1b1490f0b3ec24800","josephmaltz","2016-06-07 00:00:00",17,"batlanta","ilb","ubs"]}} w 0.030009 | |
| total_data_static_06-09-16-11:18:48: | |
| b64{{5723f6e1b149030b3ec24800&josephmaltz&2016-06-07 00:00:00&www%25%25egghero%25%25com&chicken&17&25}} c | |
| b64{{5723f6e1b149030b3ec24800&josephmaltz&2016-06-07 00:00:00&www%25%25egghero%25%25com&chicken&17&25}} w 0.030010 | |
| digger_current: SHOULD NOT TOUCH THIS FILE | |
| digger_hist_06-09-16-11:17:49: SHOULD NOT TOUCH THIS FILE | |
| ` | |
| func base64rep(s []byte) []byte { | |
| s = s[5 : len(s)-2] | |
| o := make([]byte, base64.StdEncoding.EncodedLen(len(s))) | |
| base64.StdEncoding.Encode(o, s) | |
| return o | |
| } | |
| func DecodeFixtures(fixtureString string) map[string]string { | |
| var fixtureFiles map[string]string | |
| var bases = regexp.MustCompile(`b64{{(.*)}}`) | |
| s := bases.ReplaceAllFunc([]byte(fixtureString), base64rep) | |
| err := yaml.Unmarshal(s, &fixtureFiles) | |
| if err != nil { | |
| panic(err) | |
| } | |
| return fixtureFiles | |
| } | |
| func main() { | |
| fmt.Printf("%#v\n", DecodeFixtures(fixtureFiles)) | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment